com.sun.xml.internal.ws.message.stream.StreamMessage Java Examples
The following examples show how to use
com.sun.xml.internal.ws.message.stream.StreamMessage.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MessageWrapper.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
MessageWrapper(Packet p, Message m) { super(m.getSOAPVersion()); packet = p; delegate = m; streamDelegate = (m instanceof StreamMessage) ? (StreamMessage) m : null; setMessageMedadata(p); }
Example #2
Source File: SaajEmptyNamespaceTest.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
@Test public void testResetDefaultNamespaceSAAJ() throws Exception { // Create SOAP message from XML string and process it with SAAJ reader XMLStreamReader envelope = XMLInputFactory.newFactory().createXMLStreamReader( new StringReader(INPUT_SOAP_MESSAGE)); StreamMessage streamMessage = new StreamMessage(SOAPVersion.SOAP_11, envelope, null); SAAJFactory saajFact = new SAAJFactory(); SOAPMessage soapMessage = saajFact.readAsSOAPMessage(SOAPVersion.SOAP_11, streamMessage); // Check if constructed object model meets local names and namespace expectations SOAPElement request = (SOAPElement) soapMessage.getSOAPBody().getFirstChild(); // Check top body element name Assert.assertEquals(request.getLocalName(), "SampleServiceRequest"); // Check top body element namespace Assert.assertEquals(request.getNamespaceURI(), TEST_NS); SOAPElement params = (SOAPElement) request.getFirstChild(); // Check first child name Assert.assertEquals(params.getLocalName(), "RequestParams"); // Check if first child namespace is null Assert.assertNull(params.getNamespaceURI()); // Check inner elements of the first child SOAPElement param1 = (SOAPElement) params.getFirstChild(); Assert.assertEquals(param1.getLocalName(), "Param1"); Assert.assertNull(param1.getNamespaceURI()); SOAPElement param2 = (SOAPElement) params.getChildNodes().item(1); Assert.assertEquals(param2.getLocalName(), "Param2"); Assert.assertNull(param2.getNamespaceURI()); // Check full content of SOAP body Assert.assertEquals(nodeToText(request), EXPECTED_RESULT); }
Example #3
Source File: SaajEmptyNamespaceTest.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
@Test public void testPreserveNamespacesPosition() throws Exception { // Create SOAP message from XML string and process it with SAAJ reader XMLStreamReader envelope = XMLInputFactory.newFactory().createXMLStreamReader( new StringReader(INPUT_SOAP_MESSAGE_2)); StreamMessage streamMessage = new StreamMessage(SOAPVersion.SOAP_11, envelope, null); SAAJFactory saajFact = new SAAJFactory(); SOAPMessage soapMessage = saajFact.readAsSOAPMessage(SOAPVersion.SOAP_11, streamMessage); //Get SOAP body and convert it to string representation SOAPBody body = soapMessage.getSOAPBody(); String bodyAsString = nodeToText(body); Assert.assertEquals(bodyAsString, PRESERVE_NAMESPACES_EXPECTED_RESULT); }
Example #4
Source File: StreamSOAPCodec.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
public static final Message decode(SOAPVersion soapVersion, XMLStreamReader reader, @NotNull AttachmentSet attachmentSet) { // 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); return new StreamMessage(soapVersion, reader, attachmentSet); }
Example #5
Source File: MessageWrapper.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
MessageWrapper(Packet p, Message m) { super(m.getSOAPVersion()); packet = p; delegate = m; streamDelegate = (m instanceof StreamMessage) ? (StreamMessage) m : null; setMessageMedadata(p); }
Example #6
Source File: StreamSOAPCodec.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
public static final Message decode(SOAPVersion soapVersion, XMLStreamReader reader, @NotNull AttachmentSet attachmentSet) { // 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); return new StreamMessage(soapVersion, reader, attachmentSet); }
Example #7
Source File: MessageWrapper.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
MessageWrapper(Packet p, Message m) { super(m.getSOAPVersion()); packet = p; delegate = m; streamDelegate = (m instanceof StreamMessage) ? (StreamMessage) m : null; setMessageMedadata(p); }
Example #8
Source File: StreamSOAPCodec.java From hottub with GNU General Public License v2.0 | 5 votes |
public static final Message decode(SOAPVersion soapVersion, XMLStreamReader reader, @NotNull AttachmentSet attachmentSet) { // 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); return new StreamMessage(soapVersion, reader, attachmentSet); }
Example #9
Source File: MessageWrapper.java From hottub with GNU General Public License v2.0 | 5 votes |
MessageWrapper(Packet p, Message m) { super(m.getSOAPVersion()); packet = p; delegate = m; streamDelegate = (m instanceof StreamMessage) ? (StreamMessage) m : null; setMessageMedadata(p); }
Example #10
Source File: SaajEmptyNamespaceTest.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
@Test public void testResetDefaultNamespaceSAAJ() throws Exception { // Create SOAP message from XML string and process it with SAAJ reader XMLStreamReader envelope = XMLInputFactory.newFactory().createXMLStreamReader( new StringReader(INPUT_SOAP_MESSAGE)); StreamMessage streamMessage = new StreamMessage(SOAPVersion.SOAP_11, envelope, null); SAAJFactory saajFact = new SAAJFactory(); SOAPMessage soapMessage = saajFact.readAsSOAPMessage(SOAPVersion.SOAP_11, streamMessage); // Check if constructed object model meets local names and namespace expectations SOAPElement request = (SOAPElement) soapMessage.getSOAPBody().getFirstChild(); // Check top body element name Assert.assertEquals(request.getLocalName(), "SampleServiceRequest"); // Check top body element namespace Assert.assertEquals(request.getNamespaceURI(), TEST_NS); SOAPElement params = (SOAPElement) request.getFirstChild(); // Check first child name Assert.assertEquals(params.getLocalName(), "RequestParams"); // Check if first child namespace is null Assert.assertNull(params.getNamespaceURI()); // Check inner elements of the first child SOAPElement param1 = (SOAPElement) params.getFirstChild(); Assert.assertEquals(param1.getLocalName(), "Param1"); Assert.assertNull(param1.getNamespaceURI()); SOAPElement param2 = (SOAPElement) params.getChildNodes().item(1); Assert.assertEquals(param2.getLocalName(), "Param2"); Assert.assertNull(param2.getNamespaceURI()); // Check full content of SOAP body Assert.assertEquals(nodeToText(request), EXPECTED_RESULT); }
Example #11
Source File: StreamSOAPCodec.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public static final Message decode(SOAPVersion soapVersion, XMLStreamReader reader, @NotNull AttachmentSet attachmentSet) { // 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); return new StreamMessage(soapVersion, reader, attachmentSet); }
Example #12
Source File: MessageWrapper.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
MessageWrapper(Packet p, Message m) { super(m.getSOAPVersion()); packet = p; delegate = m; streamDelegate = (m instanceof StreamMessage) ? (StreamMessage) m : null; setMessageMedadata(p); }
Example #13
Source File: SaajEmptyNamespaceTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Test public void testResetDefaultNamespaceSAAJ() throws Exception { // Create SOAP message from XML string and process it with SAAJ reader XMLStreamReader envelope = XMLInputFactory.newFactory().createXMLStreamReader( new StringReader(INPUT_SOAP_MESSAGE)); StreamMessage streamMessage = new StreamMessage(SOAPVersion.SOAP_11, envelope, null); SAAJFactory saajFact = new SAAJFactory(); SOAPMessage soapMessage = saajFact.readAsSOAPMessage(SOAPVersion.SOAP_11, streamMessage); // Check if constructed object model meets local names and namespace expectations SOAPElement request = (SOAPElement) soapMessage.getSOAPBody().getFirstChild(); // Check top body element name Assert.assertEquals(request.getLocalName(), "SampleServiceRequest"); // Check top body element namespace Assert.assertEquals(request.getNamespaceURI(), TEST_NS); SOAPElement params = (SOAPElement) request.getFirstChild(); // Check first child name Assert.assertEquals(params.getLocalName(), "RequestParams"); // Check if first child namespace is null Assert.assertNull(params.getNamespaceURI()); // Check inner elements of the first child SOAPElement param1 = (SOAPElement) params.getFirstChild(); Assert.assertEquals(param1.getLocalName(), "Param1"); Assert.assertNull(param1.getNamespaceURI()); SOAPElement param2 = (SOAPElement) params.getChildNodes().item(1); Assert.assertEquals(param2.getLocalName(), "Param2"); Assert.assertNull(param2.getNamespaceURI()); // Check full content of SOAP body Assert.assertEquals(nodeToText(request), EXPECTED_RESULT); }
Example #14
Source File: StreamSOAPCodec.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public static final Message decode(SOAPVersion soapVersion, XMLStreamReader reader, @NotNull AttachmentSet attachmentSet) { // 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); return new StreamMessage(soapVersion, reader, attachmentSet); }
Example #15
Source File: SaajEmptyNamespaceTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
@Test public void testPreserveNamespacesPosition() throws Exception { // Create SOAP message from XML string and process it with SAAJ reader XMLStreamReader envelope = XMLInputFactory.newFactory().createXMLStreamReader( new StringReader(INPUT_SOAP_MESSAGE_2)); StreamMessage streamMessage = new StreamMessage(SOAPVersion.SOAP_11, envelope, null); SAAJFactory saajFact = new SAAJFactory(); SOAPMessage soapMessage = saajFact.readAsSOAPMessage(SOAPVersion.SOAP_11, streamMessage); //Get SOAP body and convert it to string representation SOAPBody body = soapMessage.getSOAPBody(); String bodyAsString = nodeToText(body); Assert.assertEquals(bodyAsString, PRESERVE_NAMESPACES_EXPECTED_RESULT); }
Example #16
Source File: SaajEmptyNamespaceTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
@Test public void testResetDefaultNamespaceSAAJ() throws Exception { // Create SOAP message from XML string and process it with SAAJ reader XMLStreamReader envelope = XMLInputFactory.newFactory().createXMLStreamReader( new StringReader(INPUT_SOAP_MESSAGE)); StreamMessage streamMessage = new StreamMessage(SOAPVersion.SOAP_11, envelope, null); SAAJFactory saajFact = new SAAJFactory(); SOAPMessage soapMessage = saajFact.readAsSOAPMessage(SOAPVersion.SOAP_11, streamMessage); // Check if constructed object model meets local names and namespace expectations SOAPElement request = (SOAPElement) soapMessage.getSOAPBody().getFirstChild(); // Check top body element name Assert.assertEquals(request.getLocalName(), "SampleServiceRequest"); // Check top body element namespace Assert.assertEquals(request.getNamespaceURI(), TEST_NS); SOAPElement params = (SOAPElement) request.getFirstChild(); // Check first child name Assert.assertEquals(params.getLocalName(), "RequestParams"); // Check if first child namespace is null Assert.assertNull(params.getNamespaceURI()); // Check inner elements of the first child SOAPElement param1 = (SOAPElement) params.getFirstChild(); Assert.assertEquals(param1.getLocalName(), "Param1"); Assert.assertNull(param1.getNamespaceURI()); SOAPElement param2 = (SOAPElement) params.getChildNodes().item(1); Assert.assertEquals(param2.getLocalName(), "Param2"); Assert.assertNull(param2.getNamespaceURI()); // Check full content of SOAP body Assert.assertEquals(nodeToText(request), EXPECTED_RESULT); }
Example #17
Source File: SaajEmptyNamespaceTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
@Test public void testPreserveNamespacesPosition() throws Exception { // Create SOAP message from XML string and process it with SAAJ reader XMLStreamReader envelope = XMLInputFactory.newFactory().createXMLStreamReader( new StringReader(INPUT_SOAP_MESSAGE_2)); StreamMessage streamMessage = new StreamMessage(SOAPVersion.SOAP_11, envelope, null); SAAJFactory saajFact = new SAAJFactory(); SOAPMessage soapMessage = saajFact.readAsSOAPMessage(SOAPVersion.SOAP_11, streamMessage); //Get SOAP body and convert it to string representation SOAPBody body = soapMessage.getSOAPBody(); String bodyAsString = nodeToText(body); Assert.assertEquals(bodyAsString, PRESERVE_NAMESPACES_EXPECTED_RESULT); }
Example #18
Source File: StreamSOAPCodec.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public static final Message decode(SOAPVersion soapVersion, XMLStreamReader reader, @NotNull AttachmentSet attachmentSet) { // 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); return new StreamMessage(soapVersion, reader, attachmentSet); }
Example #19
Source File: MessageWrapper.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
MessageWrapper(Packet p, Message m) { super(m.getSOAPVersion()); packet = p; delegate = m; streamDelegate = (m instanceof StreamMessage) ? (StreamMessage) m : null; setMessageMedadata(p); }
Example #20
Source File: SaajEmptyNamespaceTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@Test public void testResetDefaultNamespaceSAAJ() throws Exception { // Create SOAP message from XML string and process it with SAAJ reader XMLStreamReader envelope = XMLInputFactory.newFactory().createXMLStreamReader( new StringReader(INPUT_SOAP_MESSAGE)); StreamMessage streamMessage = new StreamMessage(SOAPVersion.SOAP_11, envelope, null); SAAJFactory saajFact = new SAAJFactory(); SOAPMessage soapMessage = saajFact.readAsSOAPMessage(SOAPVersion.SOAP_11, streamMessage); // Check if constructed object model meets local names and namespace expectations SOAPElement request = (SOAPElement) soapMessage.getSOAPBody().getFirstChild(); // Check top body element name Assert.assertEquals(request.getLocalName(), "SampleServiceRequest"); // Check top body element namespace Assert.assertEquals(request.getNamespaceURI(), TEST_NS); SOAPElement params = (SOAPElement) request.getFirstChild(); // Check first child name Assert.assertEquals(params.getLocalName(), "RequestParams"); // Check if first child namespace is null Assert.assertNull(params.getNamespaceURI()); // Check inner elements of the first child SOAPElement param1 = (SOAPElement) params.getFirstChild(); Assert.assertEquals(param1.getLocalName(), "Param1"); Assert.assertNull(param1.getNamespaceURI()); SOAPElement param2 = (SOAPElement) params.getChildNodes().item(1); Assert.assertEquals(param2.getLocalName(), "Param2"); Assert.assertNull(param2.getNamespaceURI()); // Check full content of SOAP body Assert.assertEquals(nodeToText(request), EXPECTED_RESULT); }
Example #21
Source File: SaajEmptyNamespaceTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@Test public void testPreserveNamespacesPosition() throws Exception { // Create SOAP message from XML string and process it with SAAJ reader XMLStreamReader envelope = XMLInputFactory.newFactory().createXMLStreamReader( new StringReader(INPUT_SOAP_MESSAGE_2)); StreamMessage streamMessage = new StreamMessage(SOAPVersion.SOAP_11, envelope, null); SAAJFactory saajFact = new SAAJFactory(); SOAPMessage soapMessage = saajFact.readAsSOAPMessage(SOAPVersion.SOAP_11, streamMessage); //Get SOAP body and convert it to string representation SOAPBody body = soapMessage.getSOAPBody(); String bodyAsString = nodeToText(body); Assert.assertEquals(bodyAsString, PRESERVE_NAMESPACES_EXPECTED_RESULT); }
Example #22
Source File: StreamSOAPCodec.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public static final Message decode(SOAPVersion soapVersion, XMLStreamReader reader, @NotNull AttachmentSet attachmentSet) { // 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); return new StreamMessage(soapVersion, reader, attachmentSet); }
Example #23
Source File: MessageWrapper.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
MessageWrapper(Packet p, Message m) { super(m.getSOAPVersion()); packet = p; delegate = m; streamDelegate = (m instanceof StreamMessage) ? (StreamMessage) m : null; setMessageMedadata(p); }
Example #24
Source File: StreamSOAPCodec.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public static final Message decode(SOAPVersion soapVersion, XMLStreamReader reader, @NotNull AttachmentSet attachmentSet) { // 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); return new StreamMessage(soapVersion, reader, attachmentSet); }
Example #25
Source File: MessageWrapper.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
MessageWrapper(Packet p, Message m) { super(m.getSOAPVersion()); packet = p; delegate = m; streamDelegate = (m instanceof StreamMessage) ? (StreamMessage) m : null; setMessageMedadata(p); }
Example #26
Source File: SaajEmptyNamespaceTest.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Test public void testResetDefaultNamespaceSAAJ() throws Exception { // Create SOAP message from XML string and process it with SAAJ reader XMLStreamReader envelope = XMLInputFactory.newFactory().createXMLStreamReader( new StringReader(INPUT_SOAP_MESSAGE)); StreamMessage streamMessage = new StreamMessage(SOAPVersion.SOAP_11, envelope, null); SAAJFactory saajFact = new SAAJFactory(); SOAPMessage soapMessage = saajFact.readAsSOAPMessage(SOAPVersion.SOAP_11, streamMessage); // Check if constructed object model meets local names and namespace expectations SOAPElement request = (SOAPElement) soapMessage.getSOAPBody().getFirstChild(); // Check top body element name Assert.assertEquals(request.getLocalName(), "SampleServiceRequest"); // Check top body element namespace Assert.assertEquals(request.getNamespaceURI(), TEST_NS); SOAPElement params = (SOAPElement) request.getFirstChild(); // Check first child name Assert.assertEquals(params.getLocalName(), "RequestParams"); // Check if first child namespace is null Assert.assertNull(params.getNamespaceURI()); // Check inner elements of the first child SOAPElement param1 = (SOAPElement) params.getFirstChild(); Assert.assertEquals(param1.getLocalName(), "Param1"); Assert.assertNull(param1.getNamespaceURI()); SOAPElement param2 = (SOAPElement) params.getChildNodes().item(1); Assert.assertEquals(param2.getLocalName(), "Param2"); Assert.assertNull(param2.getNamespaceURI()); // Check full content of SOAP body Assert.assertEquals(nodeToText(request), EXPECTED_RESULT); }
Example #27
Source File: SaajEmptyNamespaceTest.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Test public void testPreserveNamespacesPosition() throws Exception { // Create SOAP message from XML string and process it with SAAJ reader XMLStreamReader envelope = XMLInputFactory.newFactory().createXMLStreamReader( new StringReader(INPUT_SOAP_MESSAGE_2)); StreamMessage streamMessage = new StreamMessage(SOAPVersion.SOAP_11, envelope, null); SAAJFactory saajFact = new SAAJFactory(); SOAPMessage soapMessage = saajFact.readAsSOAPMessage(SOAPVersion.SOAP_11, streamMessage); //Get SOAP body and convert it to string representation SOAPBody body = soapMessage.getSOAPBody(); String bodyAsString = nodeToText(body); Assert.assertEquals(bodyAsString, PRESERVE_NAMESPACES_EXPECTED_RESULT); }
Example #28
Source File: SaajEmptyNamespaceTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
@Test public void testResetDefaultNamespaceSAAJ() throws Exception { // Create SOAP message from XML string and process it with SAAJ reader XMLStreamReader envelope = XMLInputFactory.newFactory().createXMLStreamReader( new StringReader(INPUT_SOAP_MESSAGE)); StreamMessage streamMessage = new StreamMessage(SOAPVersion.SOAP_11, envelope, null); SAAJFactory saajFact = new SAAJFactory(); SOAPMessage soapMessage = saajFact.readAsSOAPMessage(SOAPVersion.SOAP_11, streamMessage); // Check if constructed object model meets local names and namespace expectations SOAPElement request = (SOAPElement) soapMessage.getSOAPBody().getFirstChild(); // Check top body element name Assert.assertEquals(request.getLocalName(), "SampleServiceRequest"); // Check top body element namespace Assert.assertEquals(request.getNamespaceURI(), TEST_NS); SOAPElement params = (SOAPElement) request.getFirstChild(); // Check first child name Assert.assertEquals(params.getLocalName(), "RequestParams"); // Check if first child namespace is null Assert.assertNull(params.getNamespaceURI()); // Check inner elements of the first child SOAPElement param1 = (SOAPElement) params.getFirstChild(); Assert.assertEquals(param1.getLocalName(), "Param1"); Assert.assertNull(param1.getNamespaceURI()); SOAPElement param2 = (SOAPElement) params.getChildNodes().item(1); Assert.assertEquals(param2.getLocalName(), "Param2"); Assert.assertNull(param2.getNamespaceURI()); // Check full content of SOAP body Assert.assertEquals(nodeToText(request), EXPECTED_RESULT); }