Problem: When a response is set on the messagecontext by a ClientInterceptor.handleRequest, an actual connection to the webservice is still created and the Webservice is actually accessed in hasError or hasFault. I would expect that the WebServiceTemplate would not even create a connection in this case.
Background: I tried to write a ClientInterceptor for the WebServiceTemplate that simulates an actual webservice call during a selftest of the system. ClientInterceptor.hasRequest checks whether this is during a selftest and sets the response on the MessageContext and the other system should never be contacted at all.
- As a quick fix one could extend the first if(messageContext.hasResponse() ) in WebServiceTemplate.doSendAndReceive(MessageContext, ...) to the hasError check, since this check does not make much sense if the response was not sent, does it? 8-)
- Even if this quick fix is done, MessageContext.createConnection is still called, which does not seem appropriate to me. Perhaps this should be done only later, after the interceptors have been called?