{
return false;
}
});
HttpSoapTransport soapTransport = new HttpSoapTransport();
SoapMessage message;
SoapMessage response;
// Try without a header handler
message = SoapMessageUtils.readSoapMessageFromStream(getClass().getResourceAsStream("soap-message.xml"));
try
{
response = soapTransport.sendReceive("http://localhost:8085/dtc/iya", message, null);
fail("There should have been an exception here!");
}
catch (SoapTransportException e)
{
SoapMessage msg = e.getSoapMessageWithFault();
assertNotNull(msg);
assertTrue(msg.containsFault());
assertEquals("env:MustUnderstand", msg.getBodyElement().valueOf("env:Fault/env:Code"));
}
// Try with a header handler
servlet.addHeaderHandlerMapping(QName.get("h:plop", "urn:plop:da:plop"), new ISoapHeaderHandler()
{
public SoapFault handleHeader(Element header, SoapMessage soapMessage)
{
return null;
}
});
response = soapTransport.sendReceive("http://localhost:8085/dtc/iya", message, null);
assertEquals(0, nodeComparator.compare(message, response));
// Sollicit-request
response = soapTransport.receive("http://localhost:8085/dtc/iya", null);
assertEquals(0, nodeComparator.compare(message, response));
// Try a non-existent URL
try
{
soapTransport.sendReceive("http://localhost:8085/dtc/plop", message, null);
fail("This pathinfo should not be handled");
}
catch (SoapTransportException e)
{
}