I created a client-side SOAPHandler to send an outgoing request to the server and add a SOAP header in the SOAP message. It registers the outgoing XML address with no header part. But at the end of the server I can register the entire message with the title of the soap.
Server side log:
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header>
<Credential xmlns="http://soap.header.test.com" password="123" username="ashok"/>
</SOAP-ENV:Header>
<S:Body>
<ns2:addNumber xmlns:ns2="http://service.ashok.com/">
<arg0>10</arg0>
<arg1>200</arg1>
</ns2:addNumber>
</S:Body>
Client Side Journal
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/> **NO HEADER**
<S:Body>
<ns2:addNumber xmlns:ns2="http://service.ashok.com/">
<arg0>10</arg0>
<arg1>200</arg1>
</ns2:addNumber>
</S:Body>
My partial client side SOAPHandler
if (outgoingRequest) {
SOAPMessage message = context.getMessage();
SOAPEnvelope envelope = message.getSOAPPart().getEnvelope();
SOAPHeader header = envelope.getHeader();
if (null == header) {
header = envelope.addHeader();
}
QName credential = new QName("http://soap.header.test.com","Credential");
SOAPHeaderElement headerElement = header.addHeaderElement(credential);
QName username = new QName("username");
headerElement.addAttribute(username, "ashok");
QName password = new QName("password");
headerElement.addAttribute(password, "123");
message.writeTo(System.out);
}
Please suggest me how to log a SOAP message with part of the header on the client side
source
share