A
It's not clear what the challenge is. On the one hand, you're saying, "It works great."But that's what "SOAP user report"somethings aren't valid. SOAP♪On the question. You can intercept the control at the time of departure/full. SOAP- Interviews with processors and access to a communication submitted in the form of DOM- structures. For a client, the web service is doing this. Let's announce the processor:public class TestClientHandler implements SOAPHandler<SOAPMessageContext> {
public Set<QName> getHeaders() {
return null;
}
public boolean handleMessage(SOAPMessageContext smc) {
SOAPMessage message = smc.getMessage();
Boolean outboundProperty = (Boolean) smc.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
try {
if (outboundProperty) {//если исходящее
} else {//если входящее
}
} catch (Exception e) {
e.printStackTrace();
return false;
}
return true;
}
public boolean handleFault(SOAPMessageContext context) {
return true;
}
public void close(MessageContext context) {
}
}
When we create a copy of the client's web service, we add our processor: List<Handler> list = new ArrayList<Handler>();
list.add(new TestClientHandler());
BindingProvider bp = (BindingProvider) port;
bp.getBinding().setHandlerChain(list);
Here. port - it's your web service client.On the server ' s side, the principle of action is similar, but the processor is added differently. ♪ Java- Web services class should be added @HandlerChain:@WebService(name = "MyService")
@HandlerChain(file = "ws-handler.xml")
public class MyService {...
The file should be created ws-handler.xml with such contents:<handler-chain>
<handler>
<handler-name>WS Handler</handler-name>
<handler-class>my.package.TestClientHandler</handler-class>
</handler>
</handler-chain>
Fail ws-handler.xml may be in the same package, for example, where the computerized web service class, i.e., the ritual with it.Having access DOM- communication structure, e.g. by applying methods message.getSOAPBody() and message.getSOAPHeader(), you any modification of the message. Work DOM Not always simple and understandable, I'm gonna have to deal with it separately, but that's beyond the question.