I have a service which throws a checked exception. However when I deploy this service on Tomcat (6.x) with JAX-WS 2.1.4 I get an HTTP 500 on the client side. When the same service is deployed using the JDK's Endpoint.publish the exception is handled correctly.
I had a look through the specification which has some suggestions on this issue and mentions the 500 error, however I have not been able to find a example which demonstrates how I can correct this behaviour.
The Service
@WebService
public class ServiceProvider
{
...
public synchronized Result fetch(...INPUT...) throws LicenseException
{
...
The Exception
@WebFault
public class LicenseException extends Exception
{
/** Creates a new instance of LicenseException */
public LicenseException(String message)
{
super(message);
}
public String getFaultInfo()
{
return getMessage();
}
}
After some digging I found that the exceptions are marshalled slightly differently
This is the fault generated by Endpoint.publish (handled correctly):
HTTP/1.1 500 Internal Server Error
Content-length: 507
Content-type: text/xml; charset=utf-8
<?xml version="1.0" ?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns1="http://addressbookserver.j2anywhere.com/">
<soapenv:Body>
<soapenv:Fault xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<faultcode>soapenv:Server</faultcode>
<faultstring>Unable to verify license</faultstring>
<detail><ns1:LicenseException>Unable to verify license</ns1:LicenseException></detail>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
This is the fault received from Tomcat (break the client):
HTTP/1.1 500 Internal Server Error
Server: Apache-Coyote/1.1
Content-Type: text/xml;charset=utf-8
Date: Thu, 19 Jun 2008 22:26:17 GMT
Connection: close
<?xml version="1.0" ?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<S:Fault xmlns:ns3="http://www.w3.org/2003/05/soap-envelope">
<faultcode>S:Server</faultcode>
<faultstring>Unable to verify license</faultstring>
<detail><ns2:LicenseException xmlns:ns2="http://addressbookserver.j2anywhere.com/">Unable to verify license</ns2:LicenseException></detail>
</S:Fault>
</S:Body>
</S:Envelope>
It seems that my client's soap stack is having a problem interpreting the fault from tomcat. I had a look and I am using a newer version of JAX-B, which I am guessing is responsible for the object to XML conversion. If this is the cause of my problem are there any configuration I can use to modify the behaviour of JAX-B ?
Kind regards
Alex