In a project, we have to call a web service that has exis开发者_如何学运维ted for many years and cannot be modified. This web service contains a bug: when it sends a response to a SOAP request, the response does not always contain the required <S:Envelope> and <S:Body> elements.
How can we intercept the message and insert the missing parts before it is parsed by the JAX-WS SOAP parser?
I saw that this question was still open without any answers, so I'll provide some insight on how the problem was solved.
As it is, JAX-WS doesn't offer any support to do this kind of thing. It is probably possible to look into the details of the implementation and add a hook there, but then your solution is no longer portable to other web service container implementations.
Our final solution was to switch to Commons HTTP Client to send the message and receive the response. The messages themselves were created and parsed using plain JAXB. The SOAP headers were added and removed manually.
精彩评论