The problem is resolved.
Turns out I did NOT post SOAP content. The SOAP header is configured correctly. But the SOAP body is empty. To solve this problem, I had to attach the content I am requesting.
Before:
GetDeletedRequest request = new GetDeletedRequest(); JAXBElement res = (JAXBElement) webServiceTemplate.marshalSendAndReceive(request, new WebServiceMessageCallback() {...}
After:
GetDeletedRequest request = new GetDeletedRequest(); request.setGetDeletedFilter(deleteFilter);
This error was missed by me because I focused on porting the implementation of the AXIS 1.x client to the Spring WS implementation.
Some people, including Arien Pustma, have suggested using tcpmon to sniff what is sent. I was unable to configure and run it correctly (this is another unrelated issue). But it gave me an idea to first check what was sent by my application.
I looked around and saw a similar problem in the Spring forums about invalid content type in WS Client using JAXB for sorting . The last poster suggested using CommonsHttpMessageSender, like the example that he provided in the web service client with Spring -WS (which is good). With CommonsHttpMessageSender, he was able to print the entire SOAP envelope:
<property name="messageSender"> <bean class="org.springframework.ws.transport.http.CommonsHttpMessageSender" /> </property>
I am documenting my experiences here because one day I know that there will be a guy like me who will have the same problem.
source share