Example usage for javax.xml.ws.handler MessageContext WSDL_PORT

List of usage examples for javax.xml.ws.handler MessageContext WSDL_PORT

Introduction

In this page you can find the example usage for javax.xml.ws.handler MessageContext WSDL_PORT.

Prototype

String WSDL_PORT

To view the source code for javax.xml.ws.handler MessageContext WSDL_PORT.

Click Source Link

Document

Standard property: name of WSDL port.

Usage

From source file:ddf.security.pep.interceptor.PEPAuthorizingInterceptor.java

/**
 * This method is an implementation of the WSA-M and WSA-W specs for determining the action URI.<br>
 * <ul>/*from w w w  .j  ava  2  s .  co  m*/
 * <li>http://www.w3.org/TR/ws-addr-metadata/#actioninwsdl</li>
 * <li>http://www.w3.org/TR/ws-addr-wsdl/#actioninwsdl</li>
 * </ul>
 * Adapted from {@link org.apache.cxf.ws.addressing.impl.MAPAggregatorImpl} and
 * {@link org.apache.cxf.ws.addressing.impl.InternalContextUtils}
 *
 * @param message
 * @return
 */
private String getActionUri(Message message) {
    String actionURI = null;

    /**
     * See if the action is explicitly defined in the WSDL message service model. Retrieves one
     * of the Action attribute in the wsdl:input message.
     */
    MessageInfo msgInfo = (MessageInfo) message.get(MessageInfo.class.getName());
    if (msgInfo != null && msgInfo.getExtensionAttributes() != null) {
        // wsaw:Action
        Object attr = msgInfo.getExtensionAttribute(JAXWSAConstants.WSAW_ACTION_QNAME);
        // wsam:Action
        if (attr == null) {
            attr = msgInfo.getExtensionAttribute(JAXWSAConstants.WSAM_ACTION_QNAME);
        }
        // support for older usages
        if (attr == null) {
            attr = msgInfo.getExtensionAttributes()
                    .get(new QName(JAXWSAConstants.NS_WSA, Names.WSAW_ACTION_NAME));
        }
        if (attr == null) {
            attr = msgInfo.getExtensionAttributes()
                    .get(new QName(Names.WSA_NAMESPACE_WSDL_NAME_OLD, Names.WSAW_ACTION_NAME));
        }
        if (attr instanceof QName) {
            actionURI = ((QName) attr).getLocalPart();
        } else {
            actionURI = attr == null ? null : attr.toString();
        }
    }

    /**
     * See if the action is explicitly defined in the WSDL operation service model. Retrieves
     * the operation soap:soapAction property.
     */
    if (StringUtils.isEmpty(actionURI)) {
        BindingOperationInfo bindingOpInfo = message.getExchange().get(BindingOperationInfo.class);
        SoapOperationInfo soi = bindingOpInfo.getExtensor(SoapOperationInfo.class);
        if (soi == null && bindingOpInfo.isUnwrapped()) {
            soi = bindingOpInfo.getWrappedOperation().getExtensor(SoapOperationInfo.class);
        }
        actionURI = soi == null ? null : soi.getAction();
        actionURI = StringUtils.isEmpty(actionURI) ? null : actionURI;
    }

    /**
     * If the service model doesn't explicitly defines the action, we'll construct the default
     * URI string.
     */
    if (StringUtils.isEmpty(actionURI)) {
        QName op = (QName) message.get(MessageContext.WSDL_OPERATION);
        QName port = (QName) message.get(MessageContext.WSDL_PORT);
        if (op != null && port != null) {
            actionURI = port.getNamespaceURI();
            actionURI = addPath(actionURI, port.getLocalPart());
            actionURI = addPath(actionURI, op.getLocalPart() + "Request");
        }
    }

    return actionURI;
}

From source file:org.apache.axis2.jaxws.context.WebServiceContextImpl.java

public <T extends EndpointReference> T getEndpointReference(Class<T> clazz, Element... referenceParameters) {

    // Note that the MessageContext might not be set up yet, or it
    // may have been released because the lifetime of the WebServiceContext is completed.
    if (log.isDebugEnabled()) {
        if (soapMessageContext == null) {
            log.debug("The MessageContext is not available");
        }//from ww  w .  j  a v  a2s.com
    }

    EndpointReference jaxwsEPR = null;
    String addressingNamespace = EndpointReferenceUtils.getAddressingNamespace(clazz);

    if (soapMessageContext != null) {
        QName service = (QName) soapMessageContext.get(MessageContext.WSDL_SERVICE);
        QName endpoint = (QName) soapMessageContext.get(MessageContext.WSDL_PORT);

        org.apache.axis2.addressing.EndpointReference axis2EPR = EndpointReferenceUtils
                .createAxis2EndpointReference(null, service, endpoint, null, addressingNamespace);

        try {
            EndpointReferenceUtils.addReferenceParameters(axis2EPR, referenceParameters);
            jaxwsEPR = EndpointReferenceUtils.convertFromAxis2(axis2EPR, addressingNamespace);
        } catch (Exception e) {
            throw ExceptionFactory.makeWebServiceException(
                    Messages.getMessage("endpointRefConstructionFailure3", e.toString()));
        }
    } else {
        throw new IllegalStateException(Messages.getMessage("webServiceContextErr1"));
    }

    return clazz.cast(jaxwsEPR);
}