Java Reference
In-Depth Information
public boolean handleMessage(SOAPMessageContext soapmc)
{
log(soapmc);
return true;
}
private void log(SOAPMessageContext soapmc)
{
Boolean outboundProperty = (Boolean)
soap-
mc.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
if (outboundProperty.booleanValue())
out.println("Outbound message:");
else
out.println("Inbound message:");
SOAPMessage soapm = soapmc.getMessage();
try
{
soapm.writeTo(out);
out.println("\n");
}
catch (IOException|SOAPException e)
{
out.println("Handler exception: "+e);
}
}
}
SOAPLoggingHandler first declares a java.io.PrintStream field named
out thatidentifiesthedestination.Although System.out isassignedto out ,youcan
assignadifferentoutputstreamtothisfieldforloggingSOAPmessagestoanotherdes-
tination.
SOAPHandler introducesa Set<QName> getHeaders() methodforinform-
ingtheJAX-WSruntimeabouttheSOAPheadersthatthehandlerisresponsibleforpro-
cessing. Thismethod returnsasetofqualified names forthoseSOAPmessage header
blocksthatthehandlercanprocess.Althoughwemustimplementthismethod,itreturns
null because there are no headers to process.
Search WWH ::




Custom Search