Search in sources :

Example 1 with SOAPVersion

use of com.sun.xml.ws.api.SOAPVersion 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 SOAPVersion

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

the class Messages method create.

/**
 * Creates a {@link Message} from an {@link Element} that represents
 * the whole SOAP message.
 *
 * @param soapEnvelope
 *      The SOAP envelope element.
 */
public static Message create(Element soapEnvelope) {
    SOAPVersion ver = SOAPVersion.fromNsUri(soapEnvelope.getNamespaceURI());
    // find the headers
    Element header = DOMUtil.getFirstChild(soapEnvelope, ver.nsUri, "Header");
    HeaderList headers = null;
    if (header != null) {
        for (Node n = header.getFirstChild(); n != null; n = n.getNextSibling()) {
            if (n.getNodeType() == Node.ELEMENT_NODE) {
                if (headers == null)
                    headers = new HeaderList(ver);
                headers.add(Headers.create((Element) n));
            }
        }
    }
    // find the payload
    Element body = DOMUtil.getFirstChild(soapEnvelope, ver.nsUri, "Body");
    if (body == null)
        throw new WebServiceException("Message doesn't have <S:Body> " + soapEnvelope);
    Element payload = DOMUtil.getFirstChild(soapEnvelope, ver.nsUri, "Body");
    if (payload == null) {
        return new EmptyMessageImpl(headers, new AttachmentSetImpl(), ver);
    } else {
        return new DOMMessage(ver, headers, payload);
    }
}
Also used : WebServiceException(jakarta.xml.ws.WebServiceException) SOAPVersion(com.sun.xml.ws.api.SOAPVersion) Element(org.w3c.dom.Element) XmlRootElement(jakarta.xml.bind.annotation.XmlRootElement) JAXBElement(jakarta.xml.bind.JAXBElement) Node(org.w3c.dom.Node) AttachmentSetImpl(com.sun.xml.ws.message.AttachmentSetImpl) DOMMessage(com.sun.xml.ws.message.DOMMessage) EmptyMessageImpl(com.sun.xml.ws.message.EmptyMessageImpl)

Example 3 with SOAPVersion

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

the class StreamMessage method readEnvelope.

private static void readEnvelope(StreamMessage message) {
    if (message.envelopeReader == null)
        return;
    XMLStreamReader reader = message.envelopeReader;
    message.envelopeReader = null;
    SOAPVersion soapVersion = message.soapVersion;
    // Move to soap:Envelope and verify
    if (reader.getEventType() != XMLStreamConstants.START_ELEMENT)
        XMLStreamReaderUtil.nextElementContent(reader);
    XMLStreamReaderUtil.verifyReaderState(reader, XMLStreamConstants.START_ELEMENT);
    if (SOAP_ENVELOPE.equals(reader.getLocalName()) && !soapVersion.nsUri.equals(reader.getNamespaceURI())) {
        throw new VersionMismatchException(soapVersion, soapVersion.nsUri, reader.getNamespaceURI());
    }
    XMLStreamReaderUtil.verifyTag(reader, soapVersion.nsUri, SOAP_ENVELOPE);
    TagInfoset envelopeTag = new TagInfoset(reader);
    // Collect namespaces on soap:Envelope
    Map<String, String> namespaces = new HashMap<>();
    for (int i = 0; i < reader.getNamespaceCount(); i++) {
        namespaces.put(reader.getNamespacePrefix(i), reader.getNamespaceURI(i));
    }
    // Move to next element
    XMLStreamReaderUtil.nextElementContent(reader);
    XMLStreamReaderUtil.verifyReaderState(reader, javax.xml.stream.XMLStreamConstants.START_ELEMENT);
    HeaderList headers = null;
    TagInfoset headerTag = null;
    if (reader.getLocalName().equals(SOAP_HEADER) && reader.getNamespaceURI().equals(soapVersion.nsUri)) {
        headerTag = new TagInfoset(reader);
        // Collect namespaces on soap:Header
        for (int i = 0; i < reader.getNamespaceCount(); i++) {
            namespaces.put(reader.getNamespacePrefix(i), reader.getNamespaceURI(i));
        }
        // skip <soap:Header>
        XMLStreamReaderUtil.nextElementContent(reader);
        // If SOAP header blocks are present (i.e. not <soap:Header/>)
        if (reader.getEventType() == XMLStreamConstants.START_ELEMENT) {
            headers = new HeaderList(soapVersion);
            try {
                // Cache SOAP header blocks
                StreamHeaderDecoder headerDecoder = SOAPVersion.SOAP_11.equals(soapVersion) ? SOAP11StreamHeaderDecoder : SOAP12StreamHeaderDecoder;
                cacheHeaders(reader, namespaces, headers, headerDecoder);
            } catch (XMLStreamException e) {
                // TODO need to throw more meaningful exception
                throw new WebServiceException(e);
            }
        }
        // Move to soap:Body
        XMLStreamReaderUtil.nextElementContent(reader);
    }
    // Verify that <soap:Body> is present
    XMLStreamReaderUtil.verifyTag(reader, soapVersion.nsUri, SOAP_BODY);
    TagInfoset bodyTag = new TagInfoset(reader);
    String bodyPrologue = XMLStreamReaderUtil.nextWhiteSpaceContent(reader);
    message.init(envelopeTag, headerTag, message.attachmentSet, headers, bodyPrologue, bodyTag, null, reader, soapVersion);
// when there's no payload,
// it's tempting to use EmptyMessageImpl, but it doesn't preserve the infoset
// of <envelope>,<header>, and <body>, so we need to stick to StreamMessage.
}
Also used : WebServiceException(jakarta.xml.ws.WebServiceException) HashMap(java.util.HashMap) SOAPVersion(com.sun.xml.ws.api.SOAPVersion) TagInfoset(com.sun.xml.ws.encoding.TagInfoset) HeaderList(com.sun.xml.ws.api.message.HeaderList) VersionMismatchException(com.sun.xml.ws.protocol.soap.VersionMismatchException)

Example 4 with SOAPVersion

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

the class RuntimeModeler method createBinding.

/**
 * creates a runtime model <code>SOAPBinding</code> from a <code>jakarta.jws.soap.SOAPBinding</code> object
 * @param soapBinding the <code>jakarta.jws.soap.SOAPBinding</code> to model
 * @return returns the runtime model SOAPBinding corresponding to <code>soapBinding</code>
 */
protected SOAPBindingImpl createBinding(SOAPBinding soapBinding) {
    SOAPBindingImpl rtSOAPBinding = new SOAPBindingImpl();
    Style style = soapBinding != null ? soapBinding.style() : Style.DOCUMENT;
    rtSOAPBinding.setStyle(style);
    assert bindingId != null;
    model.bindingId = bindingId;
    SOAPVersion soapVersion = bindingId.getSOAPVersion();
    rtSOAPBinding.setSOAPVersion(soapVersion);
    return rtSOAPBinding;
}
Also used : SOAPVersion(com.sun.xml.ws.api.SOAPVersion) Style(jakarta.jws.soap.SOAPBinding.Style) SOAPBindingImpl(com.sun.xml.ws.model.soap.SOAPBindingImpl)

Example 5 with SOAPVersion

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

the class RuntimeModeler method getDefaultBindingID.

private BindingID getDefaultBindingID() {
    BindingType bt = getAnnotation(portClass, BindingType.class);
    if (bt != null)
        return BindingID.parse(bt.value());
    SOAPVersion ver = WebServiceFeatureList.getSoapVersion(features);
    boolean mtomEnabled = features.isEnabled(MTOMFeature.class);
    if (SOAPVersion.SOAP_12.equals(ver)) {
        return (mtomEnabled) ? BindingID.SOAP12_HTTP_MTOM : BindingID.SOAP12_HTTP;
    } else {
        return (mtomEnabled) ? BindingID.SOAP11_HTTP_MTOM : BindingID.SOAP11_HTTP;
    }
}
Also used : SOAPVersion(com.sun.xml.ws.api.SOAPVersion)

Aggregations

SOAPVersion (com.sun.xml.ws.api.SOAPVersion)16 AddressingVersion (com.sun.xml.ws.api.addressing.AddressingVersion)4 SOAPMessage (jakarta.xml.soap.SOAPMessage)4 WebServiceException (jakarta.xml.ws.WebServiceException)4 Message (com.sun.xml.ws.api.message.Message)3 Packet (com.sun.xml.ws.api.message.Packet)3 SAAJMessage (com.sun.xml.ws.message.saaj.SAAJMessage)3 SOAPException (jakarta.xml.soap.SOAPException)3 MessageContext (com.oracle.webservices.api.message.MessageContext)2 Attachment (com.sun.xml.ws.api.message.Attachment)2 StreamingDataHandler (com.sun.xml.ws.developer.StreamingDataHandler)2 MIMEPartStreamingDataHandler (com.sun.xml.ws.encoding.MIMEPartStreamingDataHandler)2 XMLStreamException (javax.xml.stream.XMLStreamException)2 WSBinding (com.sun.xml.ws.api.WSBinding)1 WSEndpointReference (com.sun.xml.ws.api.addressing.WSEndpointReference)1 ExceptionHasMessage (com.sun.xml.ws.api.message.ExceptionHasMessage)1 Header (com.sun.xml.ws.api.message.Header)1 HeaderList (com.sun.xml.ws.api.message.HeaderList)1 ParameterBinding (com.sun.xml.ws.api.model.ParameterBinding)1 SOAPBinding (com.sun.xml.ws.api.model.soap.SOAPBinding)1