Java Code Examples for javax.xml.soap.SOAPElement#getFirstChild()
The following examples show how to use
javax.xml.soap.SOAPElement#getFirstChild() .
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: 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); }
Example 2
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 3
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 4
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 5
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 6
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 7
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 8
Source File: JaxWsHandlerTest.java From googleads-java-lib with Apache License 2.0 | 5 votes |
/** * Tests * {@link JaxWsHandler#setHeaderChildString(BindingProvider, String, String, String, String)} when * given valid inputs. */ @Test public void testSetHeaderChildString() throws Exception { String parentNamespace = "parentNamespace"; String parentName = "parentName"; when(mockSoapClient.getBinding()).thenReturn(mockBinding); when(mockBinding.getHandlerChain()).thenReturn(handlerChain); // Add the parent header. SOAPFactory soapFactory = SOAPFactory.newInstance(); SOAPElement parentHeader = soapFactory.createElement(parentName, null, parentNamespace); jaxWsHandler.setHeader(mockSoapClient, parentNamespace, parentName, parentHeader); // Add the child header. String childNamespace = "childNamespace"; String childName = "childName"; String childValue = "foo"; jaxWsHandler.setHeaderChildString(mockSoapClient, parentName, childNamespace, childName, childValue); SOAPElement parentHeaderFromHandler = (SOAPElement) jaxWsHandler.getHeader(mockSoapClient, parentName); // Retrieve the added child and assert its attributes are correct. SOAPElement childHeaderFromHandler = (SOAPElement) parentHeaderFromHandler.getFirstChild(); assertEquals("Child name incorrect", childName, childHeaderFromHandler.getNodeName()); assertEquals("Child namespace incorrect", childNamespace, childHeaderFromHandler.getNamespaceURI()); assertEquals("Child value incorrect", childValue, childHeaderFromHandler.getTextContent()); }