Search in sources :

Example 11 with SAAJMessage

use of com.sun.xml.ws.message.saaj.SAAJMessage in project metro-jax-ws by eclipse-ee4j.

the class DomUtilTester method testSOAPEnvelope2_1.

public void testSOAPEnvelope2_1() throws Exception {
    for (File f : folder.listFiles()) {
        System.out.println("***********" + f.getName() + "***********");
        SOAPMessage soapmsg = getSOAPMessage(f);
        SAAJMessage saajmessage = new SAAJMessage(soapmsg);
        XMLStreamWriter writer = staxOut.createXMLStreamWriter(new PrintStream(System.out));
        saajmessage.writeTo(writer);
        writer.close();
        assert (true);
        System.out.println("*****************************************");
    }
}
Also used : PrintStream(java.io.PrintStream) SAAJMessage(com.sun.xml.ws.message.saaj.SAAJMessage) XMLStreamWriter(javax.xml.stream.XMLStreamWriter) File(java.io.File) SOAPMessage(jakarta.xml.soap.SOAPMessage)

Example 12 with SAAJMessage

use of com.sun.xml.ws.message.saaj.SAAJMessage in project metro-jax-ws by eclipse-ee4j.

the class SAAJMessageTester method writeMessage.

private void writeMessage(InputStream in) throws Exception {
    MessageFactory mf = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
    MimeHeaders mhs = new MimeHeaders();
    mhs.addHeader("Content-Type", "text/xml");
    mhs.addHeader("Content-Transfer-Encoding", "binary");
    SOAPMessage sm = mf.createMessage(mhs, in);
    SAAJMessage msg = new SAAJMessage(sm);
    ByteArrayBuffer baos = new ByteArrayBuffer();
    XMLStreamWriter writer = XMLStreamWriterFactory.create(baos);
    msg.writeTo(writer);
    writer.flush();
}
Also used : MimeHeaders(jakarta.xml.soap.MimeHeaders) MessageFactory(jakarta.xml.soap.MessageFactory) SAAJMessage(com.sun.xml.ws.message.saaj.SAAJMessage) XMLStreamWriter(javax.xml.stream.XMLStreamWriter) SOAPMessage(jakarta.xml.soap.SOAPMessage) ByteArrayBuffer(com.sun.xml.ws.util.ByteArrayBuffer)

Example 13 with SAAJMessage

use of com.sun.xml.ws.message.saaj.SAAJMessage in project metro-jax-ws by eclipse-ee4j.

the class SAAJMessageTester method testDOMLevel1WriteTo.

public void testDOMLevel1WriteTo() throws Exception {
    DocumentBuilderFactory builderFactory = null;
    DocumentBuilder builder = null;
    MessageFactory messageFactory = MessageFactory.newInstance();
    SOAPMessage soapMessage = messageFactory.createMessage();
    SOAPEnvelope soapEnvelope = soapMessage.getSOAPPart().getEnvelope();
    soapEnvelope.setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
    soapEnvelope.setAttribute("xmlns:xsd", "http://www.w3.org/2001/XMLSchema");
    SOAPBody soapBody = soapEnvelope.getBody();
    Name elementName = soapEnvelope.createName("addNumbers", "", "http://duke.org");
    SOAPBodyElement bodyElement = soapBody.addBodyElement(elementName);
    SAAJMessage msg = new SAAJMessage(soapMessage);
    ByteArrayBuffer baos = new ByteArrayBuffer();
    XMLStreamWriter writer = XMLStreamWriterFactory.createXMLStreamWriter(baos);
    msg.writeTo(writer);
    writer.flush();
}
Also used : SOAPBody(jakarta.xml.soap.SOAPBody) DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) MessageFactory(jakarta.xml.soap.MessageFactory) DocumentBuilder(javax.xml.parsers.DocumentBuilder) SAAJMessage(com.sun.xml.ws.message.saaj.SAAJMessage) XMLStreamWriter(javax.xml.stream.XMLStreamWriter) SOAPEnvelope(jakarta.xml.soap.SOAPEnvelope) SOAPMessage(jakarta.xml.soap.SOAPMessage) Name(jakarta.xml.soap.Name) QName(javax.xml.namespace.QName) SOAPBodyElement(jakarta.xml.soap.SOAPBodyElement) ByteArrayBuffer(com.sun.xml.ws.util.ByteArrayBuffer)

Example 14 with SAAJMessage

use of com.sun.xml.ws.message.saaj.SAAJMessage in project metro-jax-ws by eclipse-ee4j.

the class SAAJMessageTester method init.

private void init() {
    MessageFactory mf = null;
    try {
        mf = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
        MimeHeaders mhs = new MimeHeaders();
        mhs.addHeader("Content-Type", "text/xml");
        mhs.addHeader("Content-Transfer-Encoding", "binary");
        SOAPMessage sm = mf.createMessage(mhs, new ByteArrayInputStream(soap11Msg.getBytes()));
        msg = new SAAJMessage(sm);
    } catch (SOAPException e) {
        e.printStackTrace();
        assertTrue(false);
    } catch (IOException e) {
        e.printStackTrace();
        assertTrue(false);
    }
}
Also used : MimeHeaders(jakarta.xml.soap.MimeHeaders) MessageFactory(jakarta.xml.soap.MessageFactory) ByteArrayInputStream(java.io.ByteArrayInputStream) SAAJMessage(com.sun.xml.ws.message.saaj.SAAJMessage) SOAPException(jakarta.xml.soap.SOAPException) IOException(java.io.IOException) SOAPMessage(jakarta.xml.soap.SOAPMessage)

Example 15 with SAAJMessage

use of com.sun.xml.ws.message.saaj.SAAJMessage in project metro-jax-ws by eclipse-ee4j.

the class SaajMessageTest method testBodyAttr.

public void testBodyAttr() throws Exception {
    MessageFactory factory = MessageFactory.newInstance();
    SOAPMessage message = factory.createMessage();
    Source src = new StreamSource(new ByteArrayInputStream(MESSAGE_535.getBytes()));
    message.getSOAPPart().setContent(src);
    SAAJMessage saajMsg = new SAAJMessage(message);
    // breaks the underlying SOAPMessage
    saajMsg.hasHeaders();
    Source source = saajMsg.readEnvelopeAsSource();
    SOAPMessage newMsg = factory.createMessage();
    newMsg.getSOAPPart().setContent(source);
    SOAPBody body = newMsg.getSOAPBody();
    assertEquals("value", body.getAttribute("attr"));
}
Also used : SOAPBody(jakarta.xml.soap.SOAPBody) MessageFactory(jakarta.xml.soap.MessageFactory) ByteArrayInputStream(java.io.ByteArrayInputStream) SAAJMessage(com.sun.xml.ws.message.saaj.SAAJMessage) StreamSource(javax.xml.transform.stream.StreamSource) SOAPMessage(jakarta.xml.soap.SOAPMessage) StreamSource(javax.xml.transform.stream.StreamSource) Source(javax.xml.transform.Source)

Aggregations

SAAJMessage (com.sun.xml.ws.message.saaj.SAAJMessage)27 SOAPMessage (jakarta.xml.soap.SOAPMessage)19 ByteArrayInputStream (java.io.ByteArrayInputStream)18 MessageFactory (jakarta.xml.soap.MessageFactory)16 MimeHeaders (jakarta.xml.soap.MimeHeaders)12 Packet (com.sun.xml.ws.api.message.Packet)10 Element (org.w3c.dom.Element)10 WSEndpointReference (com.sun.xml.ws.api.addressing.WSEndpointReference)7 Message (com.sun.xml.ws.api.message.Message)5 SOAPFaultException (jakarta.xml.ws.soap.SOAPFaultException)5 QName (javax.xml.namespace.QName)4 XMLStreamWriter (javax.xml.stream.XMLStreamWriter)4 Node (org.w3c.dom.Node)4 SOAPVersion (com.sun.xml.ws.api.SOAPVersion)3 SOAPBody (jakarta.xml.soap.SOAPBody)3 AddressingVersion (com.sun.xml.ws.api.addressing.AddressingVersion)2 SOAPFaultBuilder (com.sun.xml.ws.fault.SOAPFaultBuilder)2 ByteArrayBuffer (com.sun.xml.ws.util.ByteArrayBuffer)2 File (java.io.File)2 ArrayList (java.util.ArrayList)2