Reputation: 5168
I used wizard in Eclipse to add JAX-WS Handler to my project. It implementes SOAPHandler.
Then, in Project Explorer, under JAX-WS Web Services > Service Endpoint Interfaces > MyServiceSoap, I used option to Configure Handlers. I pointed to my Handler class and new file was created handler-chain.xml in the same folder where my MyServiceSoap.java file is.
I've looked into my MyServiceSoap.java and I see declaration @HandlerChain(file = "handler-chain.xml")
So, as far as I know, all pieces are in place. But, when I attempt to call this service, handleMessage never gets called.
Here is my handleMessage code:
@Override
public boolean handleMessage(SOAPMessageContext context) {
SOAPMessage msg = context.getMessage();
return true;
}
I set break point in this method with hope that I will be able to see content of the message that is being sent to remote web service. I also have to note that currently I am getting error "WebServiceException: No Content-type in the header" when I attempt to use this service. So, maybe, this error is happening before handleMessage has chance to run.
I would appreciate it if anybody can provide more light to this subject. Thanks.
Upvotes: 4
Views: 6440
Reputation: 43
I had the same problem, but my client was generated by maven using jaxws:wsimport. My Handler never was called, so the solution was to declare @HandlerChain(file="MyHandlerFile.xml")
, the Xml file (in this case) should be inside in the same package where is your class, example:
com.my.package.MyClientWS.java
com.my.package.MyHandlerFile.xml
Declaring annotation:
@WebService(.....)
@HandlerChain(file="MyHandlerFile.xml")<br>
public class MyClientWS extends Service ....
Handler Chain File:
<?xml version="1.0" encoding="UTF-8"?>
<handler-chains xmlns="http://java.sun.com/xml/ns/javaee">
<handler-chain>
<handler>
<handler-name>package.to.my.MyHandler<handler-name>
<handler-class>package.to.my.MyHandler</handler-class>
</handler>
</handler-chain>
</handler-chains>
Upvotes: 4