Search in sources :

Example 11 with MimeHeaders

use of jakarta.xml.soap.MimeHeaders in project metro-jax-ws by eclipse-ee4j.

the class ReferenceParametersTest method testReferenceParameters1.

public void testReferenceParameters1() throws Exception {
    String xmlRefParam1 = "<myns:MyParam1 wsa:IsReferenceParameter='true' xmlns:myns=\"http://cptestservice.org/wsdl\" xmlns:wsa=\"http://www.w3.org/2005/08/addressing\">Hello</myns:MyParam1>";
    String xmlRefParam2 = "<myns:MyParam2 wsa:IsReferenceParameter='true' xmlns:myns=\"http://cptestservice.org/wsdl\" xmlns:wsa=\"http://www.w3.org/2005/08/addressing\">There</myns:MyParam2>";
    String request = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<S:Envelope xmlns:S=\"http://schemas.xmlsoap.org/soap/envelope/\"><S:Header>" + xmlRefParam1 + xmlRefParam2 + "</S:Header><S:Body><DataType xmlns=\"http://cptestservice.org/xsd\"><param>foo bar</param></DataType></S:Body></S:Envelope>";
    MessageFactory messageFactory = MessageFactory.newInstance();
    MimeHeaders headers = new MimeHeaders();
    headers.addHeader("Content-Type", "text/xml");
    SOAPMessage soapMsg = messageFactory.createMessage(headers, new ByteArrayInputStream(request.getBytes()));
    // soapMsg.writeTo(System.out);
    Packet p = new Packet(new SAAJMessage(soapMsg));
    List<Element> refParams = p.getReferenceParameters();
    assertEquals("Did n't get expected ReferenceParameters", 2, refParams.size());
    for (Element e : refParams) {
        assertTrue("isReferenceParameter attribute not present on header", e.getAttributeNodeNS(W3CAddressingConstants.WSA_NAMESPACE_NAME, "IsReferenceParameter") != null);
    }
}
Also used : MimeHeaders(jakarta.xml.soap.MimeHeaders) Packet(com.sun.xml.ws.api.message.Packet) MessageFactory(jakarta.xml.soap.MessageFactory) ByteArrayInputStream(java.io.ByteArrayInputStream) SAAJMessage(com.sun.xml.ws.message.saaj.SAAJMessage) Element(org.w3c.dom.Element) SOAPMessage(jakarta.xml.soap.SOAPMessage)

Example 12 with MimeHeaders

use of jakarta.xml.soap.MimeHeaders in project metro-jax-ws by eclipse-ee4j.

the class ReferenceParametersTest method testReferenceParameters2.

public void testReferenceParameters2() throws Exception {
    String xmlParam1 = "<myns:MyParam1 xmlns:myns=\"http://cptestservice.org/wsdl\">Hello</myns:MyParam1>";
    String xmlParam2 = "<myns:MyParam2 xmlns:myns=\"http://cptestservice.org/wsdl\"><myns:InnerEl> Hello Hello </myns:InnerEl></myns:MyParam2>";
    String request = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<S:Envelope xmlns:S=\"http://schemas.xmlsoap.org/soap/envelope/\"><S:Body><DataType xmlns=\"http://cptestservice.org/xsd\"><param>foo bar</param></DataType></S:Body></S:Envelope>";
    MessageFactory messageFactory = MessageFactory.newInstance();
    MimeHeaders headers = new MimeHeaders();
    headers.addHeader("Content-Type", "text/xml");
    SOAPMessage soapMsg = messageFactory.createMessage(headers, new ByteArrayInputStream(request.getBytes()));
    Packet p = new Packet(new SAAJMessage(soapMsg));
    List<Element> refparams = new ArrayList<Element>();
    Node n1 = DOMUtil.createDOMNode(new ByteArrayInputStream(xmlParam1.getBytes()));
    Node n2 = DOMUtil.createDOMNode(new ByteArrayInputStream(xmlParam2.getBytes()));
    refparams.add((Element) n1.getFirstChild());
    refparams.add((Element) n2.getFirstChild());
    WSEndpointReference wsepr = new WSEndpointReference(AddressingVersion.W3C, "http://foo.bar", null, null, null, null, null, refparams);
    wsepr.addReferenceParametersToList(p.getMessage().getHeaders());
    // p.getMessage().writeTo(XMLOutputFactory.newInstance().createXMLStreamWriter(System.out));
    List<Element> refParams = p.getReferenceParameters();
    assertEquals("Did n't get expected ReferenceParameters", 2, refParams.size());
    for (Element e : refParams) {
        assertTrue("isReferenceParameter attribute not present on header", e.getAttributeNodeNS(W3CAddressingConstants.WSA_NAMESPACE_NAME, "IsReferenceParameter") != null);
    }
}
Also used : MimeHeaders(jakarta.xml.soap.MimeHeaders) Packet(com.sun.xml.ws.api.message.Packet) MessageFactory(jakarta.xml.soap.MessageFactory) ByteArrayInputStream(java.io.ByteArrayInputStream) SAAJMessage(com.sun.xml.ws.message.saaj.SAAJMessage) Element(org.w3c.dom.Element) Node(org.w3c.dom.Node) WSEndpointReference(com.sun.xml.ws.api.addressing.WSEndpointReference) ArrayList(java.util.ArrayList) SOAPMessage(jakarta.xml.soap.SOAPMessage)

Example 13 with MimeHeaders

use of jakarta.xml.soap.MimeHeaders 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 14 with MimeHeaders

use of jakarta.xml.soap.MimeHeaders 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 MimeHeaders

use of jakarta.xml.soap.MimeHeaders in project spring-integration by spring-projects.

the class DefaultSoapHeaderMapperTests method testDoNotOverriderSoapAction.

@Test
public void testDoNotOverriderSoapAction() throws Exception {
    MimeHeaders mimeHeaders = new MimeHeaders();
    String testSoapAction = "fooAction";
    mimeHeaders.setHeader(TransportConstants.HEADER_SOAP_ACTION, testSoapAction);
    String soap = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"></soapenv:Envelope>";
    SOAPMessage message = MessageFactory.newInstance().createMessage(mimeHeaders, new ByteArrayInputStream(soap.getBytes()));
    SaajSoapMessage soapMessage = new SaajSoapMessage(message);
    DefaultSoapHeaderMapper headerMapper = new DefaultSoapHeaderMapper();
    headerMapper.fromHeadersToRequest(new MessageHeaders(null), soapMessage);
    assertThat(soapMessage.getSoapAction()).isEqualTo(testSoapAction);
}
Also used : MimeHeaders(jakarta.xml.soap.MimeHeaders) SaajSoapMessage(org.springframework.ws.soap.saaj.SaajSoapMessage) ByteArrayInputStream(java.io.ByteArrayInputStream) MessageHeaders(org.springframework.messaging.MessageHeaders) SOAPMessage(jakarta.xml.soap.SOAPMessage) Test(org.junit.Test)

Aggregations

MimeHeaders (jakarta.xml.soap.MimeHeaders)30 SOAPMessage (jakarta.xml.soap.SOAPMessage)27 ByteArrayInputStream (java.io.ByteArrayInputStream)24 MessageFactory (jakarta.xml.soap.MessageFactory)19 Packet (com.sun.xml.ws.api.message.Packet)13 SAAJMessage (com.sun.xml.ws.message.saaj.SAAJMessage)12 Element (org.w3c.dom.Element)12 Message (com.sun.xml.ws.api.message.Message)7 QName (javax.xml.namespace.QName)7 WSEndpointReference (com.sun.xml.ws.api.addressing.WSEndpointReference)6 BindingProvider (jakarta.xml.ws.BindingProvider)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 InputStream (java.io.InputStream)4 Node (org.w3c.dom.Node)4 MessageContextFactory (com.oracle.webservices.api.message.MessageContextFactory)3 AttachmentPart (jakarta.xml.soap.AttachmentPart)3 SOAPException (jakarta.xml.soap.SOAPException)3 MTOMFeature (jakarta.xml.ws.soap.MTOMFeature)3 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3