Search in sources :

Example 6 with SOAPVersion

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

the class DispatchImpl method dumpParam.

private void dumpParam(T param, String method) {
    if (param instanceof Packet) {
        Packet message = (Packet) param;
        String action;
        String msgId;
        if (LOGGER.isLoggable(Level.FINE)) {
            AddressingVersion av = DispatchImpl.this.getBinding().getAddressingVersion();
            SOAPVersion sv = DispatchImpl.this.getBinding().getSOAPVersion();
            action = av != null && message.getMessage() != null ? AddressingUtils.getAction(message.getMessage().getHeaders(), av, sv) : null;
            msgId = av != null && message.getMessage() != null ? AddressingUtils.getMessageID(message.getMessage().getHeaders(), av, sv) : null;
            LOGGER.fine("In DispatchImpl." + method + " for message with action: " + action + " and msg ID: " + msgId + " msg: " + message.getMessage());
            if (message.getMessage() == null) {
                LOGGER.fine("Dispatching null message for action: " + action + " and msg ID: " + msgId);
            }
        }
    }
}
Also used : Packet(com.sun.xml.ws.api.message.Packet) AddressingVersion(com.sun.xml.ws.api.addressing.AddressingVersion) SOAPVersion(com.sun.xml.ws.api.SOAPVersion)

Example 7 with SOAPVersion

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

the class SAAJMessageTest method testMtomAttachmentCid.

public void testMtomAttachmentCid() throws Exception {
    String testMtomMessageReload_01 = "multipart/related;type=\"application/xop+xml\";boundary=\"----=_Part_0_1145105632.1353005695468\";start=\"<cbe648b3-2055-413e-b8ed-877cdf0f2477>\";start-info=\"text/xml\"";
    MessageContext m1 = mcf.createContext(getResource("testMtomMessageReload_01.msg"), testMtomMessageReload_01);
    Packet packet = (Packet) m1;
    Message riMsg = packet.getInternalMessage();
    // This will cause all the attachments to be created ...
    // Iterator<Attachment> as = packet.getInternalMessage().getAttachments().iterator();
    // SAAJFactory:
    SOAPVersion soapVersion = packet.getMessage().getSOAPVersion();
    SOAPMessage saajMsg = soapVersion.getMessageFactory().createMessage();
    SaajStaxWriterEx writer = new SaajStaxWriterEx(saajMsg, soapVersion.nsUri);
    try {
        riMsg.writeTo(writer);
    } catch (XMLStreamException e) {
        throw (e.getCause() instanceof SOAPException) ? (SOAPException) e.getCause() : new SOAPException(e);
    }
    saajMsg = writer.getSOAPMessage();
    int counter = 0;
    String hredCid = null;
    for (Attachment a : riMsg.getAttachments()) {
        hredCid = ((StreamingDataHandler) a.asDataHandler()).getHrefCid();
        counter++;
    }
    assertTrue(writer.ma.size() == counter);
    AttachmentPart ap = null;
    // for (Iterator<AttachmentPart> itr = saajMsg.getAttachments(); itr.hasNext(); ) {
    // System.out.println("\r\n itr.next().getContentId()  " + itr.next().getContentId() );
    // }
    StreamingDataHandler sdh = (StreamingDataHandler) writer.ma.get(0);
    assertEquals(hredCid, sdh.getHrefCid());
}
Also used : Packet(com.sun.xml.ws.api.message.Packet) Message(com.sun.xml.ws.api.message.Message) SOAPMessage(jakarta.xml.soap.SOAPMessage) Attachment(com.sun.xml.ws.api.message.Attachment) AttachmentPart(jakarta.xml.soap.AttachmentPart) SOAPMessage(jakarta.xml.soap.SOAPMessage) XMLStreamException(javax.xml.stream.XMLStreamException) SOAPVersion(com.sun.xml.ws.api.SOAPVersion) SOAPException(jakarta.xml.soap.SOAPException) MessageContext(com.oracle.webservices.api.message.MessageContext) MIMEPartStreamingDataHandler(com.sun.xml.ws.encoding.MIMEPartStreamingDataHandler) StreamingDataHandler(com.sun.xml.ws.developer.StreamingDataHandler)

Example 8 with SOAPVersion

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

the class SAAJMessageTest method testMtomAttachment.

public void testMtomAttachment() throws Exception {
    String testMtomMessageReload_01 = "multipart/related;type=\"application/xop+xml\";boundary=\"----=_Part_0_1145105632.1353005695468\";start=\"<cbe648b3-2055-413e-b8ed-877cdf0f2477>\";start-info=\"text/xml\"";
    MessageContext m1 = mcf.createContext(getResource("testMtomMessageReload_01.msg"), testMtomMessageReload_01);
    Packet packet = (Packet) m1;
    Message message = packet.getInternalMessage();
    Iterator<Attachment> as = packet.getInternalMessage().getAttachments().iterator();
    Attachment att = null;
    int counter = 0;
    String cid1 = null;
    while (as.hasNext()) {
        att = as.next();
        cid1 = att.getContentId();
        counter++;
    }
    assertTrue(counter == 1);
    // SAAJFactory:
    SOAPVersion soapVersion = packet.getMessage().getSOAPVersion();
    SOAPMessage msg = soapVersion.getMessageFactory().createMessage();
    SaajStaxWriterEx writer = new SaajStaxWriterEx(msg, soapVersion.nsUri);
    try {
        message.writeTo(writer);
    } catch (XMLStreamException e) {
        throw (e.getCause() instanceof SOAPException) ? (SOAPException) e.getCause() : new SOAPException(e);
    }
    msg = writer.getSOAPMessage();
    counter = 0;
    String cid2 = null;
    for (Attachment a : message.getAttachments()) {
        counter++;
        cid2 = a.getContentId();
    }
    assertTrue(writer.ma.size() == counter);
    StreamingDataHandler sdh = (StreamingDataHandler) writer.ma.get(0);
    assertEquals(cid1, sdh.getHrefCid());
    assertEquals(cid2, sdh.getHrefCid());
}
Also used : Packet(com.sun.xml.ws.api.message.Packet) Message(com.sun.xml.ws.api.message.Message) SOAPMessage(jakarta.xml.soap.SOAPMessage) Attachment(com.sun.xml.ws.api.message.Attachment) SOAPMessage(jakarta.xml.soap.SOAPMessage) XMLStreamException(javax.xml.stream.XMLStreamException) SOAPVersion(com.sun.xml.ws.api.SOAPVersion) SOAPException(jakarta.xml.soap.SOAPException) MessageContext(com.oracle.webservices.api.message.MessageContext) MIMEPartStreamingDataHandler(com.sun.xml.ws.encoding.MIMEPartStreamingDataHandler) StreamingDataHandler(com.sun.xml.ws.developer.StreamingDataHandler)

Example 9 with SOAPVersion

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

the class HttpAdapter method encodePacket.

private void encodePacket(@NotNull Packet packet, @NotNull WSHTTPConnection con, @NotNull Codec codec) throws IOException {
    if (isNonAnonymousUri(packet.endpointAddress) && packet.getMessage() != null) {
        try {
            // Message is targeted to non-anonymous response endpoint.
            // After call to non-anonymous processor, typically, packet.getMessage() will be null
            // however, processors could use this pattern to modify the response sent on the back-channel,
            // e.g. send custom HTTP headers with the HTTP 202
            packet = getNonAnonymousResponseProcessor().process(packet);
        } catch (RuntimeException re) {
            // if processing by NonAnonymousResponseProcessor fails, new SOAPFaultMessage is created to be sent
            // to back-channel client
            SOAPVersion soapVersion = packet.getBinding().getSOAPVersion();
            Message faultMsg = SOAPFaultBuilder.createSOAPFaultMessage(soapVersion, null, re);
            packet = packet.createServerResponse(faultMsg, packet.endpoint.getPort(), null, packet.endpoint.getBinding());
        }
    }
    if (con.isClosed()) {
        // Connection is already closed
        return;
    }
    Message responseMessage = packet.getMessage();
    addStickyCookie(con);
    addReplicaCookie(con, packet);
    if (responseMessage == null) {
        if (!con.isClosed()) {
            // for example, 415 may have been set earlier for Unsupported Content-Type
            if (con.getStatus() == 0) {
                con.setStatus(WSHTTPConnection.ONEWAY);
            }
            OutputStream os = con.getProtocol().contains("1.1") ? con.getOutput() : new Http10OutputStream(con);
            if (dump || LOGGER.isLoggable(Level.FINER)) {
                ByteArrayBuffer buf = new ByteArrayBuffer();
                codec.encode(packet, buf);
                dump(buf, "HTTP response " + con.getStatus(), con.getResponseHeaders());
                buf.writeTo(os);
            } else {
                codec.encode(packet, os);
            }
            // close the response channel now
            try {
                // no payload
                os.close();
            } catch (IOException e) {
                throw new WebServiceException(e);
            }
        }
    } else {
        if (con.getStatus() == 0) {
            // if the appliation didn't set the status code,
            // set the default one.
            con.setStatus(responseMessage.isFault() ? HttpURLConnection.HTTP_INTERNAL_ERROR : HttpURLConnection.HTTP_OK);
        }
        if (isClientErrorStatus(con.getStatus())) {
            OutputStream os = con.getOutput();
            if (dump || LOGGER.isLoggable(Level.FINER)) {
                ByteArrayBuffer buf = new ByteArrayBuffer();
                writeClientError(con.getStatus(), buf, packet);
                dump(buf, "HTTP response " + con.getStatus(), con.getResponseHeaders());
                buf.writeTo(os);
            } else {
                writeClientError(con.getStatus(), os, packet);
            }
            os.close();
            return;
        }
        ContentType contentType = codec.getStaticContentType(packet);
        if (contentType != null) {
            con.setContentTypeResponseHeader(contentType.getContentType());
            OutputStream os = con.getProtocol().contains("1.1") ? con.getOutput() : new Http10OutputStream(con);
            if (dump || LOGGER.isLoggable(Level.FINER)) {
                ByteArrayBuffer buf = new ByteArrayBuffer();
                codec.encode(packet, buf);
                dump(buf, "HTTP response " + con.getStatus(), con.getResponseHeaders());
                buf.writeTo(os);
            } else {
                codec.encode(packet, os);
            }
            os.close();
        } else {
            ByteArrayBuffer buf = new ByteArrayBuffer();
            contentType = codec.encode(packet, buf);
            con.setContentTypeResponseHeader(contentType.getContentType());
            if (dump || LOGGER.isLoggable(Level.FINER)) {
                dump(buf, "HTTP response " + con.getStatus(), con.getResponseHeaders());
            }
            OutputStream os = con.getOutput();
            buf.writeTo(os);
            os.close();
        }
    }
}
Also used : Message(com.sun.xml.ws.api.message.Message) ExceptionHasMessage(com.sun.xml.ws.api.message.ExceptionHasMessage) WebServiceException(jakarta.xml.ws.WebServiceException) ContentType(com.sun.xml.ws.api.pipe.ContentType) SOAPVersion(com.sun.xml.ws.api.SOAPVersion) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OutputStream(java.io.OutputStream) IOException(java.io.IOException) ByteArrayBuffer(com.sun.xml.ws.util.ByteArrayBuffer)

Example 10 with SOAPVersion

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

the class DomUtilTester method getSOAPMessage.

public SOAPMessage getSOAPMessage(File f) throws Exception {
    SOAPVersion version = SOAPVersion.SOAP_11;
    if (f.getName().endsWith("_12.xml")) {
        version = SOAPVersion.SOAP_12;
    }
    MessageFactory mf = version.saajMessageFactory;
    SOAPMessage sm = mf.createMessage(null, new FileInputStream(f));
    return sm;
}
Also used : MessageFactory(jakarta.xml.soap.MessageFactory) SOAPVersion(com.sun.xml.ws.api.SOAPVersion) SOAPMessage(jakarta.xml.soap.SOAPMessage) FileInputStream(java.io.FileInputStream)

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