Search in sources :

Example 1 with AddressingVersion

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

the class GenerateToElementTest method testCorrectToFromResMsg.

public void testCorrectToFromResMsg() throws Exception {
    String reqMsgStr = "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:a=\"http://www.w3.org/2005/08/addressing\">" + "<s:Header>" + "<a:Action s:mustUnderstand=\"1\">http://example.org/action/echoIn</a:Action>" + "<a:ReplyTo s:actor=\"http://www.w3.org/2003/05/soap-envelope/role/none\"><a:Address>http://www.microsoft.com/</a:Address></a:ReplyTo>" + "<a:MessageID>urn:uuid:d715800d-67e2-4254-a86e-e31a1bfaecab</a:MessageID>" + "<a:ReplyTo><a:Address>http://10.244.13.245:8000/2eaddcdf-e10b-41c5-9f1f-a7ac50853fc3/4b1de783-1499-4419-9634-465f8797a0a8</a:Address></a:ReplyTo>" + "<a:To s:mustUnderstand=\"1\">http://scl58353.us.oracle.com:9902/WSAddressingCR_Service_WCF/WSAddressing10.svc/Echo4</a:To>" + "</s:Header>" + "<s:Body>" + "<echoIn xmlns=\"http://example.org/echo\">test1151</echoIn>" + "</s:Body>" + "</s:Envelope>";
    String respMsgStr = "<?xml version='1.0' encoding='UTF-8'?>" + "<S:Envelope xmlns:S=\"http://schemas.xmlsoap.org/soap/envelope/\">" + "<S:Body>" + "<ns0:echoOut xmlns:ns0=\"http://example.org/echo\">test1151</ns0:echoOut>" + "</S:Body>" + "</S:Envelope>";
    String finalToFromResponseMsg = "";
    WSEndpointReference originalReplyToFromRequestMsg = null;
    AddressingVersion av = AddressingVersion.W3C;
    SOAPVersion sv = SOAPVersion.SOAP_11;
    String action = "http://example.org/action/echoOut";
    SAAJMessage reqMsg = new SAAJMessage(makeSOAPMessage(reqMsgStr));
    SAAJMessage respMsg = new SAAJMessage(makeSOAPMessage(respMsgStr));
    HeaderList requestHdrs = (HeaderList) reqMsg.getHeaders();
    originalReplyToFromRequestMsg = requestHdrs.getReplyTo(av, sv);
    Packet responsePacket = null;
    try {
        responsePacket = new Packet(reqMsg).createServerResponse(respMsg, av, sv, action);
    } catch (Exception e) {
        e.printStackTrace();
    }
    // check toHeader
    finalToFromResponseMsg = AddressingUtils.getTo(responsePacket.getHeaderList(), av, sv);
    assertEquals(finalToFromResponseMsg, originalReplyToFromRequestMsg.getAddress());
}
Also used : AddressingVersion(com.sun.xml.ws.api.addressing.AddressingVersion) SOAPVersion(com.sun.xml.ws.api.SOAPVersion) SAAJMessage(com.sun.xml.ws.message.saaj.SAAJMessage) WSEndpointReference(com.sun.xml.ws.api.addressing.WSEndpointReference)

Example 2 with AddressingVersion

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

the class Messages method createAddressingFaultMessage.

/**
 * Creates a fault {@link Message} that captures the code/subcode/subsubcode
 * defined by WS-Addressing if one of the expected WS-Addressing headers is
 * missing in the message
 *
 * @param binding WSBinding
 * @param p
 *      {@link Packet} that was missing a WS-Addressing header.
 * @param missingHeader The missing WS-Addressing Header
 * @return
 *      A message representing SOAPFault that contains the WS-Addressing code/subcode/subsubcode.
 */
public static Message createAddressingFaultMessage(WSBinding binding, Packet p, QName missingHeader) {
    AddressingVersion av = binding.getAddressingVersion();
    if (av == null) {
        // Addressing is not enabled.
        throw new WebServiceException(AddressingMessages.ADDRESSING_SHOULD_BE_ENABLED());
    }
    WsaTubeHelper helper = av.getWsaHelper(null, null, binding);
    return create(helper.newMapRequiredFault(new MissingAddressingHeaderException(missingHeader, p)));
}
Also used : AddressingVersion(com.sun.xml.ws.api.addressing.AddressingVersion) WebServiceException(jakarta.xml.ws.WebServiceException) WsaTubeHelper(com.sun.xml.ws.addressing.WsaTubeHelper) MissingAddressingHeaderException(com.sun.xml.ws.addressing.model.MissingAddressingHeaderException)

Example 3 with AddressingVersion

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

the class Packet method populateAddressingHeaders.

private void populateAddressingHeaders(WSBinding binding, Packet responsePacket, WSDLPort wsdlPort, SEIModel seiModel) {
    AddressingVersion addressingVersion = binding.getAddressingVersion();
    if (addressingVersion == null) {
        return;
    }
    WsaTubeHelper wsaHelper = addressingVersion.getWsaHelper(wsdlPort, seiModel, binding);
    String action = responsePacket.getMessage().isFault() ? wsaHelper.getFaultAction(this, responsePacket) : wsaHelper.getOutputAction(this);
    if (action == null) {
        LOGGER.info("WSA headers are not added as value for wsa:Action cannot be resolved for this message");
        return;
    }
    populateAddressingHeaders(responsePacket, addressingVersion, binding.getSOAPVersion(), action, AddressingVersion.isRequired(binding));
}
Also used : AddressingVersion(com.sun.xml.ws.api.addressing.AddressingVersion) WsaTubeHelper(com.sun.xml.ws.addressing.WsaTubeHelper)

Example 4 with AddressingVersion

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

the class Packet method relateServerResponse.

public Packet relateServerResponse(@Nullable Packet r, @Nullable WSDLPort wsdlPort, @Nullable SEIModel seiModel, @NotNull WSBinding binding) {
    relatePackets(r, false);
    r.setState(State.ServerResponse);
    AddressingVersion av = binding.getAddressingVersion();
    // populate WS-A headers only if WS-A is enabled
    if (av == null) {
        return r;
    }
    if (getMessage() == null) {
        return r;
    }
    // populate WS-A headers only if the request has addressing headers
    String inputAction = AddressingUtils.getAction(getMessage().getHeaders(), av, binding.getSOAPVersion());
    if (inputAction == null) {
        return r;
    }
    // if one-way, then dont populate any WS-A headers
    if (r.getMessage() == null || (wsdlPort != null && getMessage().isOneWay(wsdlPort))) {
        return r;
    }
    // otherwise populate WS-Addressing headers
    populateAddressingHeaders(binding, r, wsdlPort, seiModel);
    return r;
}
Also used : AddressingVersion(com.sun.xml.ws.api.addressing.AddressingVersion)

Example 5 with AddressingVersion

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

the class Stub method getWSEndpointReference.

@Override
public final WSEndpointReference getWSEndpointReference() {
    if (binding.getBindingID().equals(HTTPBinding.HTTP_BINDING)) {
        throw new java.lang.UnsupportedOperationException(ClientMessages.UNSUPPORTED_OPERATION("BindingProvider.getEndpointReference(Class<T> class)", "XML/HTTP Binding", "SOAP11 or SOAP12 Binding"));
    }
    if (endpointReference != null) {
        return endpointReference;
    }
    String eprAddress = requestContext.getEndpointAddress().toString();
    QName portTypeName = null;
    String wsdlAddress = null;
    List<WSEndpointReference.EPRExtension> wsdlEPRExtensions = new ArrayList<>();
    if (wsdlPort != null) {
        portTypeName = wsdlPort.getBinding().getPortTypeName();
        wsdlAddress = eprAddress + "?wsdl";
        // gather EPRExtensions specified in WSDL.
        try {
            WSEndpointReference wsdlEpr = wsdlPort.getEPR();
            if (wsdlEpr != null) {
                for (WSEndpointReference.EPRExtension extnEl : wsdlEpr.getEPRExtensions()) {
                    wsdlEPRExtensions.add(new WSEPRExtension(XMLStreamBuffer.createNewBufferFromXMLStreamReader(extnEl.readAsXMLStreamReader()), extnEl.getQName()));
                }
            }
        } catch (XMLStreamException ex) {
            throw new WebServiceException(ex);
        }
    }
    AddressingVersion av = AddressingVersion.W3C;
    this.endpointReference = new WSEndpointReference(av, eprAddress, getServiceName(), getPortName(), portTypeName, null, wsdlAddress, null, wsdlEPRExtensions, null);
    return this.endpointReference;
}
Also used : WebServiceException(jakarta.xml.ws.WebServiceException) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) XMLStreamException(javax.xml.stream.XMLStreamException) AddressingVersion(com.sun.xml.ws.api.addressing.AddressingVersion) WSEPRExtension(com.sun.xml.ws.addressing.WSEPRExtension) WSEndpointReference(com.sun.xml.ws.api.addressing.WSEndpointReference) WSEPRExtension(com.sun.xml.ws.addressing.WSEPRExtension)

Aggregations

AddressingVersion (com.sun.xml.ws.api.addressing.AddressingVersion)13 SOAPVersion (com.sun.xml.ws.api.SOAPVersion)4 WsaTubeHelper (com.sun.xml.ws.addressing.WsaTubeHelper)3 WSEndpointReference (com.sun.xml.ws.api.addressing.WSEndpointReference)3 WebServiceException (jakarta.xml.ws.WebServiceException)3 MemberSubmissionAddressingFeature (com.sun.xml.ws.developer.MemberSubmissionAddressingFeature)2 SAAJMessage (com.sun.xml.ws.message.saaj.SAAJMessage)2 QName (javax.xml.namespace.QName)2 WSEPRExtension (com.sun.xml.ws.addressing.WSEPRExtension)1 MissingAddressingHeaderException (com.sun.xml.ws.addressing.model.MissingAddressingHeaderException)1 AddressingPropertySet (com.sun.xml.ws.api.addressing.AddressingPropertySet)1 OneWayFeature (com.sun.xml.ws.api.addressing.OneWayFeature)1 Packet (com.sun.xml.ws.api.message.Packet)1 WSDLBoundOperation (com.sun.xml.ws.api.model.wsdl.WSDLBoundOperation)1 BindingImpl (com.sun.xml.ws.binding.BindingImpl)1 Dispatch (jakarta.xml.ws.Dispatch)1 WebServiceFeature (jakarta.xml.ws.WebServiceFeature)1 AddressingFeature (jakarta.xml.ws.soap.AddressingFeature)1 SOAPFaultException (jakarta.xml.ws.soap.SOAPFaultException)1 ArrayList (java.util.ArrayList)1