Search in sources :

Example 11 with ByteArrayBuffer

use of com.sun.xml.ws.util.ByteArrayBuffer 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 12 with ByteArrayBuffer

use of com.sun.xml.ws.util.ByteArrayBuffer 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 13 with ByteArrayBuffer

use of com.sun.xml.ws.util.ByteArrayBuffer in project metro-jax-ws by eclipse-ee4j.

the class SerializableWebServiceExceptionTest method testClientTransportExSerial3.

/**
 * Tests argument with null
 * @throws Exception
 */
public void testClientTransportExSerial3() throws Exception {
    WebServiceException wse_orig = new ClientTransportException(ClientMessages.localizableFAILED_TO_PARSE(new URL("http://example.com?wsdl"), null));
    ClientTransportException cte_orig = (ClientTransportException) wse_orig;
    ByteArrayBuffer buffer = new ByteArrayBuffer();
    ObjectOutputStream oos = new ObjectOutputStream(buffer);
    oos.writeObject(wse_orig);
    ObjectInputStream ois = new ObjectInputStream(buffer.newInputStream());
    WebServiceException wse_ser = (WebServiceException) ois.readObject();
    ObjectInputStream ois1 = new ObjectInputStream(buffer.newInputStream());
    ClientTransportException cte_ser = (ClientTransportException) ois1.readObject();
    assertEquals(cte_orig.getLocalizedMessage(), cte_ser.getLocalizedMessage());
    assertEquals(cte_orig.getResourceBundleName(), cte_ser.getResourceBundleName());
    assertEquals(cte_orig.getKey(), cte_ser.getKey());
    assert (cte_orig.getArguments().length == cte_ser.getArguments().length);
    assertEquals(cte_orig.getArguments()[0], cte_ser.getArguments()[0]);
    assertEquals(cte_orig.getArguments()[1], cte_ser.getArguments()[1]);
}
Also used : ClientTransportException(com.sun.xml.ws.client.ClientTransportException) WebServiceException(jakarta.xml.ws.WebServiceException) ObjectOutputStream(java.io.ObjectOutputStream) URL(java.net.URL) ByteArrayBuffer(com.sun.xml.ws.util.ByteArrayBuffer) ObjectInputStream(java.io.ObjectInputStream)

Example 14 with ByteArrayBuffer

use of com.sun.xml.ws.util.ByteArrayBuffer in project metro-jax-ws by eclipse-ee4j.

the class EPRWriteNReadTest method verifyEPR.

private static void verifyEPR(WSEndpointReference wsepr) throws Exception {
    ByteArrayBuffer bytebuffer = new ByteArrayBuffer();
    XMLStreamWriter w = XMLOutputFactory.newInstance().createXMLStreamWriter(bytebuffer);
    System.out.println("----------------------------------------------------------------------");
    w.writeStartDocument();
    wsepr.writeTo("EndpointReference", w);
    w.writeEndDocument();
    System.out.println(bytebuffer.toString());
    // verify the validity of infoset by reading it as EPR back again
    EndpointReference epr = W3CEndpointReference.readFrom(new StreamSource(bytebuffer.newInputStream()));
    // Verify it good old way
    XMLStreamReader xsr = XMLInputFactory.newInstance().createXMLStreamReader(new StreamSource(bytebuffer.newInputStream()));
    QName q = new QName("http://schemas.xmlsoap.org/ws/2006/02/addressingidentity", "Identity");
    while (xsr.hasNext()) {
        xsr.next();
        if (xsr.getEventType() == XMLStreamConstants.START_ELEMENT && xsr.getLocalName().equals("Identity")) {
            assertEquals(q.getNamespaceURI(), xsr.getNamespaceURI());
        }
    }
}
Also used : QName(javax.xml.namespace.QName) StreamSource(javax.xml.transform.stream.StreamSource) ByteArrayBuffer(com.sun.xml.ws.util.ByteArrayBuffer) W3CEndpointReference(jakarta.xml.ws.wsaddressing.W3CEndpointReference) WSEndpointReference(com.sun.xml.ws.api.addressing.WSEndpointReference) EndpointReference(jakarta.xml.ws.EndpointReference)

Example 15 with ByteArrayBuffer

use of com.sun.xml.ws.util.ByteArrayBuffer in project metro-jax-ws by eclipse-ee4j.

the class StreamMessageTest method testMessageWriteTo1.

public void testMessageWriteTo1() throws Exception {
    String soapMsg = "<S:Envelope xmlns:S=\"http://schemas.xmlsoap.org/soap/envelope/\">" + "<S:Header>" + "</S:Header>" + "<S:Body>" + "<GetCountryCodesResponse xmlns='http://www.strikeiron.com'> <GetCountryCodesResult/></GetCountryCodesResponse>" + "</S:Body>" + "</S:Envelope>";
    Message message = createSOAP11StreamMessage(soapMsg);
    ByteArrayBuffer baos = new ByteArrayBuffer();
    XMLStreamWriter writer = XMLStreamWriterFactory.create(baos);
    message.writeTo(writer);
    writer.flush();
    baos.writeTo(System.out);
}
Also used : Message(com.sun.xml.ws.api.message.Message) StreamMessage(com.sun.xml.ws.message.stream.StreamMessage) XMLStreamWriter(javax.xml.stream.XMLStreamWriter) ByteArrayBuffer(com.sun.xml.ws.util.ByteArrayBuffer)

Aggregations

ByteArrayBuffer (com.sun.xml.ws.util.ByteArrayBuffer)29 XMLStreamWriter (javax.xml.stream.XMLStreamWriter)13 Message (com.sun.xml.ws.api.message.Message)9 WebServiceException (jakarta.xml.ws.WebServiceException)9 Packet (com.sun.xml.ws.api.message.Packet)7 ClientTransportException (com.sun.xml.ws.client.ClientTransportException)7 SAAJMessage (com.sun.xml.ws.message.saaj.SAAJMessage)6 SOAPMessage (jakarta.xml.soap.SOAPMessage)6 IOException (java.io.IOException)6 WSEndpointReference (com.sun.xml.ws.api.addressing.WSEndpointReference)5 ObjectInputStream (java.io.ObjectInputStream)5 ObjectOutputStream (java.io.ObjectOutputStream)5 Transformer (javax.xml.transform.Transformer)5 StreamSource (javax.xml.transform.stream.StreamSource)5 XMLInputFactory (javax.xml.stream.XMLInputFactory)4 XMLStreamReader (javax.xml.stream.XMLStreamReader)4 URL (java.net.URL)3 XMLStreamException (javax.xml.stream.XMLStreamException)3 TransformerException (javax.xml.transform.TransformerException)3 DOMResult (javax.xml.transform.dom.DOMResult)3