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

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

Introduction

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

Prototype

String WSDL_OPERATION

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

Click Source Link

Document

Standard property: name of WSDL operation.

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>//w w  w .ja v  a  2s .com
 * <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.juddi.xlt.util.LoggingHandler.java

private String getOperationName(SOAPMessageContext context) {
    // service is optional :-(
    QName service = (QName) context.get(MessageContext.WSDL_SERVICE);
    if (service == null) {
        service = new QName("<unknown>");
    }/* w  w w .  ja v a  2  s  .  co  m*/

    // operation is optional :-(
    QName operation = (QName) context.get(MessageContext.WSDL_OPERATION);
    if (operation == null) {
        // operation = new QName("<unknown>");

        try {
            operation = new QName(context.getMessage().getSOAPBody().getFirstChild().getLocalName());
        } catch (SOAPException ex) {
            throw new RuntimeException("", ex);
        }
    }

    return service.getLocalPart() + "." + operation.getLocalPart();
}