@Test public void testCopyNamespacesSOAP11() throws Exception { _composer.setCopyNamespaces(true); SOAPMessage soapMessage = SOAPUtil.createMessage(javax.xml.ws.soap.SOAPBinding.SOAP11HTTP_BINDING); soapMessage.getSOAPPart().getEnvelope().addNamespaceDeclaration("foobarns", "urn:foobarns"); soapMessage.getSOAPBody().addBodyElement(new QName("urn:test", "foobar")); logger.info( String.format("before compose:[\n%s]", XMLHelper.toPretty(soapMessage.getSOAPPart()))); SOAPBindingData sbd = new SOAPBindingData(soapMessage); Node res = _composer.compose(sbd, _exchange).getContent(Node.class); logger.info(String.format("after compose:[\n%s]", XMLHelper.toPretty(res))); String envPrefix = soapMessage.getSOAPPart().getEnvelope().getPrefix(); String envNS = soapMessage.getSOAPPart().getEnvelope().getNamespaceURI(envPrefix); String resNS = res.lookupNamespaceURI(envPrefix); Assert.assertEquals(envNS, resNS); Assert.assertEquals("urn:foobarns", res.lookupNamespaceURI("foobarns")); }
@Before public void before() { _exchange = Mockito.mock(ExchangeImpl.class, Mockito.RETURNS_DEEP_STUBS); _message = new DefaultMessage(); Mockito.when(_exchange.createMessage()).thenReturn(_message); _composer = new SOAPMessageComposer(); _composer.setContextMapper( new SOAPContextMapper() { public void mapFrom(SOAPBindingData sbd, Context context) { return; } }); }