custom exception received by ws client as AxisFault with bla
jpowerwa Nov 9, 2005 7:50 PMI am trying to get custom exceptions working from a web service on JBoss 4.0.2. The custom exception is being written into the SOAP response properly, at least to my eyes, but it is not being deserialized properly by the client. It comes across as an AxisFault with no cause or detail. The detailMessage is filled in properly, but that's it. There is no indication of the exception class, so I can't do anything with it. It looks like this:
RemoteException re=AxisFault
* cause=null
* detail=null
* detail Message="The given login or password is invalid."
The custom exception is a subclass of Java.lang.Exception. It has one data member: a String named message. The bean serializer and deserializer are registered. The exception shows up in the wsdl and mapping files properly, as far as I can tell. The wsdl is generated by java2wsdl and the mapping file is generated by wscompile.
I have tried making the exception a subclass of AxisFault, based on a recommendation I found on the web, but that didn't help. In fact, then the SOAP response did not contain the right exception class information anymore.
I've tried experimenting with the --typeMappingVersion option in java2wsdl, to no avail.
I've tried experimenting with the methods in my exception class. First, with a constructor that takes the message and only a getter, as specified for JAX-RPC. I've also tried adding a default constructor and setter, but that didn't help.
I know that I can wrap the exception in a RemoteException on the server and then pull the exception classname out on the client side, but then the SOAP isn't nice and interoperable, so I'd rather not do that.
I have been banging my head against this for too long, now, and I would really appreciate any help.
----------------------------------------------------------------------
Here are the artifacts:
From SOAP response:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<soapenv:Fault>
soapenv:Client
The given login or password is invalid.
<fault xsi:type="ns1:AuthenticationCredentialsException" xmlns:ns1="http://security.enterprise.foo.com">
<message xsi:type="xsd:string">The given login or password is invalid.
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
----------------------------------------------------------------------
From jax-rpc mapping file:
<java-xml-type-mapping>
<java-type>com.foo.enterprise.security.AuthenticationCredentialsException</java-type>
<root-type-qname xmlns:typeNS="http://security.enterprise.foo.com">typeNS:AuthenticationCredentialsException</root-type-qname>
<qname-scope>complexType</qname-scope>
<variable-mapping>
<java-variable-name>message</java-variable-name>
<xml-element-name>message</xml-element-name>
<exception-mapping>
<exception-type>com.foo.enterprise.security.AuthenticationCredentialsException</exception-type>
<wsdl-message xmlns:exMsgNS="http://security.enterprise.foo.com">exMsgNS:AuthenticationCredentialsException</wsdl-message>
<constructor-parameter-order>
<element-name>message</element-name>
</constructor-parameter-order>
</exception-mapping>
----------------------------------------------------------------------
From wsdl:
< schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://security.enterprise.foo.com">
...
< complexType name="AuthenticationCredentialsException">
< sequence>
< element name="message" nillable="true" type="soapenc:string"/>
< /sequence>
< /complexType>
< / schema>
...
<wsdl:message name="AuthenticationCredentialsException">
<wsdl:part name="fault" type="tns2:AuthenticationCredentialsException"/>
</wsdl:message>
...
<wsdl:portType name="AuthenticationJse">
<wsdl:operation name="authenticate" parameterOrder="in0 in1 in2">
<wsdl:input name="authenticateRequest" message="impl:authenticateRequest"/>
<wsdl:output name="authenticateResponse" message="impl:authenticateResponse"/>
<wsdl:fault name="AuthenticationCredentialsException" message="impl:AuthenticationCredentialsException"/>
</wsdl:operation>
</wsdl:portType>
...
<wsdl:binding name="AuthenticationJsePortSoapBinding" type="impl:AuthenticationJse">
<wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="authenticate">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="authenticateRequest">
<wsdlsoap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://tws.foo.com"/>
</wsdl:input>
<wsdl:output name="authenticateResponse">
<wsdlsoap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://tws.foo.com"/>
</wsdl:output>
<wsdl:fault name="AuthenticationCredentialsException">
<wsdlsoap:fault name="AuthenticationCredentialsException" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://tws.foo.com"/>
</wsdl:fault>
</wsdl:operation>
</wsdl:binding>