//Test The InputMessage of testHeader1 Operation
soapContext.put(ObjectMessageContext.MESSAGE_INPUT, true);
Method testHeader2 = SOAPMessageUtil.getMethod(TestHeader.class, "testHeader2");
assertNotNull(testHeader2);
objContext.setMethod(testHeader2);
TestHeader2Response arg0 = new TestHeader2Response();
arg0.setResponseType("BodyVal2");
TestHeader2Response arg1 = new TestHeader2Response();
arg1.setResponseType("HeaderVal2");
Object[] args = SOAPMessageUtil.getMessageObjects(testHeader2, null, arg0, arg1);
objContext.setMessageObjects(args);
//Write the SOAP Headers for testHeader2 operation - tests out headers
binding.marshal(
objContext,
soapContext,
new JAXBDataBindingCallback(testHeader2,
DataBindingCallback.Mode.PARTS,
null));
SOAPMessage msg = soapContext.getMessage();
assertNotNull(msg);
//Test the Header Part Only
assertNotNull(msg.getSOAPHeader());
assertTrue(msg.getSOAPHeader().hasChildNodes());
NodeList list = msg.getSOAPHeader().getChildNodes();
assertEquals(1, list.getLength());
Element headerElement = (Element)list.item(0);
//Check for mustUndrstand Attribute
assertEquals("true", headerElement
.getAttributeNS(SOAPConstants.HEADER_MUSTUNDERSTAND.getNamespaceURI(),
SOAPConstants.HEADER_MUSTUNDERSTAND.getLocalPart()));
//TestHeader3 has child elements.
assertTrue(headerElement.hasChildNodes());
list = headerElement.getChildNodes();
assertEquals(1, list.getLength());
assertEquals(arg1.getResponseType(), list.item(0).getFirstChild().getNodeValue());
//TestHeader5 return Header
Method testHeader5 = SOAPMessageUtil.getMethod(TestHeader.class, "testHeader5");
assertNotNull(testHeader5);
objContext.setMethod(testHeader5);