Binding<?> binding = getBinding("HelloWorld-RPC.wsdl");
PhaseInterceptorChain phaseIn = new PhaseInterceptorChain();
phaseIn.add(binding.getInterceptors(Phase.ServerIn));
Message msg = new MessageImpl();
msg.put(Binding.class, binding);
msg.setContent(InputStream.class, getClass().getResourceAsStream("HelloWorld-RPC-Input.xml"));
msg.put(MessageExchangeFactory.class, new MockExchangeFactory());
phaseIn.doIntercept(msg);
NormalizedMessage nm = msg.getContent(NormalizedMessage.class);
Document doc = DomUtil.parse(nm.getContent());
baos = new ByteArrayOutputStream();
DomUtil.getTransformerFactory().newTransformer().transform(nm.getContent(), new StreamResult(baos));
log.info(baos.toString());
Element root = DomUtil.getFirstChildElement(doc);
assertNotNull(msg);
assertEquals(JbiConstants.WSDL11_WRAPPER_NAMESPACE, root.getNamespaceURI());
assertEquals("message", root.getLocalName());
assertEquals("Hello", root.getAttribute("name"));
// check part "header1"
Element wrapper = DomUtil.getFirstChildElement(root);
assertNotNull(wrapper);
assertEquals(JbiConstants.WSDL11_WRAPPER_NAMESPACE, wrapper.getNamespaceURI());
assertEquals("part", wrapper.getLocalName());
Element header1 = DomUtil.getFirstChildElement(wrapper);
assertNotNull(header1);
assertEquals("uri:HelloWorld", header1.getNamespaceURI());
assertEquals("HelloHeader1", header1.getLocalName());
Element id1 = DomUtil.getFirstChildElement(header1);
assertNotNull(id1);
assertEquals("uri:HelloWorld", id1.getNamespaceURI());
assertEquals("id1", id1.getLocalName());
assertEquals("abcdefghij", id1.getTextContent());
// check part "header2"
wrapper = DomUtil.getNextSiblingElement(wrapper);
assertNotNull(wrapper);
assertEquals(JbiConstants.WSDL11_WRAPPER_NAMESPACE, wrapper.getNamespaceURI());
assertEquals("part", wrapper.getLocalName());
Element header2 = DomUtil.getFirstChildElement(wrapper);
assertNotNull(header2);
assertEquals("uri:HelloWorld", header2.getNamespaceURI());
assertEquals("HelloHeader2", header2.getLocalName());
Element id2 = DomUtil.getFirstChildElement(header2);
assertNotNull(id2);
assertEquals("uri:HelloWorld", id2.getNamespaceURI());
assertEquals("id2", id2.getLocalName());
assertEquals("1234567890", id2.getTextContent());
// check part "param1"
wrapper = DomUtil.getNextSiblingElement(wrapper);
assertNotNull(wrapper);
assertEquals(JbiConstants.WSDL11_WRAPPER_NAMESPACE, wrapper.getNamespaceURI());
assertEquals("part", wrapper.getLocalName());
assertNull(DomUtil.getFirstChildElement(wrapper));
assertEquals("foo", wrapper.getTextContent());
// check part "param2"
wrapper = DomUtil.getNextSiblingElement(wrapper);
assertNotNull(wrapper);
assertEquals(JbiConstants.WSDL11_WRAPPER_NAMESPACE, wrapper.getNamespaceURI());
assertEquals("part", wrapper.getLocalName());
assertNull(DomUtil.getFirstChildElement(wrapper));
assertEquals("bar", wrapper.getTextContent());
PhaseInterceptorChain phaseOut = new PhaseInterceptorChain();
phaseOut.add(binding.getInterceptors(Phase.ClientOut));
baos = new ByteArrayOutputStream();
Message msgOut = new MessageImpl();
msgOut.put(Binding.class, binding);
msgOut.setContent(OutputStream.class, baos);
msgOut.setContent(MessageExchange.class, msg.getContent(MessageExchange.class));
msgOut.setContent(NormalizedMessage.class, nm);
msgOut.put(SoapVersion.class, msg.get(SoapVersion.class));
phaseOut.doIntercept(msgOut);
log.info(baos.toString());
Document node = DomUtil.parse(new ByteArrayInputStream(baos.toByteArray()));
Element envelope = DomUtil.getFirstChildElement(node);