Search in sources :

Example 1 with WSDLOperationMapping

use of com.sun.xml.ws.api.model.WSDLOperationMapping in project metro-jax-ws by eclipse-ee4j.

the class ActionBasedOperationFinder method getWSDLOperationMapping.

public WSDLOperationMapping getWSDLOperationMapping(Packet request) throws DispatchException {
    MessageHeaders hl = request.getMessage().getHeaders();
    String action = AddressingUtils.getAction(hl, av, binding.getSOAPVersion());
    if (action == null)
        // Addressing is not enagaged, return null to use other ways to dispatch.
        return null;
    Message message = request.getMessage();
    QName payloadName;
    String localPart = message.getPayloadLocalPart();
    if (localPart == null) {
        payloadName = PayloadQNameBasedOperationFinder.EMPTY_PAYLOAD;
    } else {
        String nsUri = message.getPayloadNamespaceURI();
        if (nsUri == null)
            nsUri = PayloadQNameBasedOperationFinder.EMPTY_PAYLOAD_NSURI;
        payloadName = new QName(nsUri, localPart);
    }
    WSDLOperationMapping opMapping = uniqueOpSignatureMap.get(new ActionBasedOperationSignature(action, payloadName));
    if (opMapping != null)
        return opMapping;
    // Seems like in Wstrust STS wsdls, the payload does not match what is specified in the wsdl leading to incorrect
    // wsdl operation resolution. Use just wsa:Action to dispatch as a last resort.
    // try just with wsa:Action
    opMapping = actionMap.get(action);
    if (opMapping != null)
        return opMapping;
    // invalid action header
    Message result = Messages.create(action, av, binding.getSOAPVersion());
    throw new DispatchException(result);
}
Also used : WSDLOperationMapping(com.sun.xml.ws.api.model.WSDLOperationMapping) Message(com.sun.xml.ws.api.message.Message) QName(javax.xml.namespace.QName) MessageHeaders(com.sun.xml.ws.api.message.MessageHeaders)

Example 2 with WSDLOperationMapping

use of com.sun.xml.ws.api.model.WSDLOperationMapping in project metro-jax-ws by eclipse-ee4j.

the class OperationDispatcher method getWSDLOperationMapping.

/**
 * @param request Packet
 * @return the wsdl operation.
 * @throws DispatchException if a unique operartion cannot be associated with this packet.
 */
@NotNull
public WSDLOperationMapping getWSDLOperationMapping(Packet request) throws DispatchException {
    WSDLOperationMapping opName;
    for (WSDLOperationFinder finder : opFinders) {
        opName = finder.getWSDLOperationMapping(request);
        if (opName != null)
            return opName;
    }
    // No way to dispatch this request
    String err = MessageFormat.format("Request=[SOAPAction={0},Payload='{'{1}'}'{2}]", request.soapAction, request.getMessage().getPayloadNamespaceURI(), request.getMessage().getPayloadLocalPart());
    String faultString = ServerMessages.DISPATCH_CANNOT_FIND_METHOD(err);
    Message faultMsg = SOAPFaultBuilder.createSOAPFaultMessage(binding.getSOAPVersion(), faultString, binding.getSOAPVersion().faultCodeClient);
    throw new DispatchException(faultMsg);
}
Also used : WSDLOperationMapping(com.sun.xml.ws.api.model.WSDLOperationMapping) Message(com.sun.xml.ws.api.message.Message) NotNull(com.sun.istack.NotNull)

Example 3 with WSDLOperationMapping

use of com.sun.xml.ws.api.model.WSDLOperationMapping in project metro-jax-ws by eclipse-ee4j.

the class PayloadQNameBasedOperationFinder method getWSDLOperationMapping.

/**
 * @return not null if it finds a unique handler for the request
 *         null if it cannot identify a unique wsdl operation from the Payload QName.
 *
 * @throws DispatchException if the payload itself is incorrect, this happens when the payload is not accepted by
 *          any operation in the port.
 */
public WSDLOperationMapping getWSDLOperationMapping(Packet request) throws DispatchException {
    Message message = request.getMessage();
    String localPart = message.getPayloadLocalPart();
    String nsUri;
    if (localPart == null) {
        localPart = EMPTY_PAYLOAD_LOCAL;
        nsUri = EMPTY_PAYLOAD_NSURI;
    } else {
        nsUri = message.getPayloadNamespaceURI();
        if (nsUri == null)
            nsUri = EMPTY_PAYLOAD_NSURI;
    }
    WSDLOperationMapping op = methodHandlers.get(nsUri, localPart);
    // Check if payload itself is correct. Usually it is, so let us check last
    if (op == null && !unique.containsKey(nsUri, localPart)) {
        String dispatchKey = "{" + nsUri + "}" + localPart;
        String faultString = ServerMessages.DISPATCH_CANNOT_FIND_METHOD(dispatchKey);
        throw new DispatchException(SOAPFaultBuilder.createSOAPFaultMessage(binding.getSOAPVersion(), faultString, binding.getSOAPVersion().faultCodeClient));
    }
    return op;
}
Also used : WSDLOperationMapping(com.sun.xml.ws.api.model.WSDLOperationMapping) Message(com.sun.xml.ws.api.message.Message)

Example 4 with WSDLOperationMapping

use of com.sun.xml.ws.api.model.WSDLOperationMapping in project metro-jax-ws by eclipse-ee4j.

the class WsaTubeHelper method getOutputAction.

public String getOutputAction(Packet packet) {
    // String action = AddressingVersion.UNSET_OUTPUT_ACTION;
    String action = null;
    WSDLOperationMapping wsdlOp = packet.getWSDLOperationMapping();
    if (wsdlOp != null) {
        JavaMethod javaMethod = wsdlOp.getJavaMethod();
        if (javaMethod != null) {
            JavaMethodImpl jm = (JavaMethodImpl) javaMethod;
            if (jm != null && jm.getOutputAction() != null && !jm.getOutputAction().equals("")) {
                return jm.getOutputAction();
            }
        }
        WSDLBoundOperation wbo = wsdlOp.getWSDLBoundOperation();
        if (wbo != null)
            return getOutputAction(wbo);
    }
    return action;
}
Also used : WSDLOperationMapping(com.sun.xml.ws.api.model.WSDLOperationMapping) JavaMethodImpl(com.sun.xml.ws.model.JavaMethodImpl) WSDLBoundOperation(com.sun.xml.ws.api.model.wsdl.WSDLBoundOperation) JavaMethod(com.sun.xml.ws.api.model.JavaMethod)

Example 5 with WSDLOperationMapping

use of com.sun.xml.ws.api.model.WSDLOperationMapping in project metro-jax-ws by eclipse-ee4j.

the class WsaTubeHelper method getFaultActionFromSEIModel.

String getFaultActionFromSEIModel(Packet requestPacket, Packet responsePacket) {
    String action = null;
    if (seiModel == null || wsdlPort == null) {
        return action;
    }
    try {
        SOAPMessage sm = responsePacket.getMessage().copy().readAsSOAPMessage();
        if (sm == null) {
            return action;
        }
        if (sm.getSOAPBody() == null) {
            return action;
        }
        if (sm.getSOAPBody().getFault() == null) {
            return action;
        }
        Detail detail = sm.getSOAPBody().getFault().getDetail();
        if (detail == null) {
            return action;
        }
        String ns = detail.getFirstChild().getNamespaceURI();
        String name = detail.getFirstChild().getLocalName();
        WSDLOperationMapping wsdlOp = requestPacket.getWSDLOperationMapping();
        JavaMethodImpl jm = (wsdlOp != null) ? (JavaMethodImpl) wsdlOp.getJavaMethod() : null;
        if (jm != null) {
            for (CheckedExceptionImpl ce : jm.getCheckedExceptions()) {
                if (ce.getDetailType().tagName.getLocalPart().equals(name) && ce.getDetailType().tagName.getNamespaceURI().equals(ns)) {
                    return ce.getFaultAction();
                }
            }
        }
        return action;
    } catch (SOAPException e) {
        throw new WebServiceException(e);
    }
}
Also used : WSDLOperationMapping(com.sun.xml.ws.api.model.WSDLOperationMapping) JavaMethodImpl(com.sun.xml.ws.model.JavaMethodImpl) WebServiceException(jakarta.xml.ws.WebServiceException) SOAPException(jakarta.xml.soap.SOAPException) CheckedExceptionImpl(com.sun.xml.ws.model.CheckedExceptionImpl) SOAPMessage(jakarta.xml.soap.SOAPMessage) Detail(jakarta.xml.soap.Detail)

Aggregations

WSDLOperationMapping (com.sun.xml.ws.api.model.WSDLOperationMapping)9 WSDLBoundOperation (com.sun.xml.ws.api.model.wsdl.WSDLBoundOperation)5 Message (com.sun.xml.ws.api.message.Message)3 WSDLOperation (com.sun.xml.ws.api.model.wsdl.WSDLOperation)3 JavaMethodImpl (com.sun.xml.ws.model.JavaMethodImpl)2 NotNull (com.sun.istack.NotNull)1 MessageHeaders (com.sun.xml.ws.api.message.MessageHeaders)1 JavaMethod (com.sun.xml.ws.api.model.JavaMethod)1 CheckedExceptionImpl (com.sun.xml.ws.model.CheckedExceptionImpl)1 Detail (jakarta.xml.soap.Detail)1 SOAPException (jakarta.xml.soap.SOAPException)1 SOAPMessage (jakarta.xml.soap.SOAPMessage)1 WebServiceException (jakarta.xml.ws.WebServiceException)1 QName (javax.xml.namespace.QName)1