I have a WSDL from which I need to create a web service implementation. I use Eclipse and Axis1.4 and work on Weblogic9.2.
Creating server stubs is going fine and I implemented the code I need. However, for compatibility with the exising implementation, we emulate, I need to return SOAP errors for some specific error conditions.
That is, I need the body of the SOAP response to look like this:
<soapenv:Body> <soapenv:Fault> <faultcode xmlns:ns1="foobar">ns1:1234</faultcode> <faultstring>The supplied parameter name ABCD is not recognised.</faultstring> <detail> <FaultDetail>An error processing the web service [MyService]: Unknown parameter:ABCD</FaultDetail> <ns2:hostname xmlns:ns2="http://xml.apache.org/axis/">planet</ns2:hostname> </detail> </soapenv:Fault> </soapenv:Body>
From the (many) googling, I think I would have to do this by throwing a SOAPFaultException. But the message stub only throws java.rmi.RemoteException, so I tried to throw a SOAPFaultExceptionException. This gives me something like this:
<soapenv:Body> <soapenv:Fault> <faultcode>soapenv:Server.userException</faultcode> <faultstring>java.rmi.RemoteException: My remote exception; nested exception is: javax.xml.rpc.soap.SOAPFaultException: soap fault string</faultstring> <detail> <ns1:hostname xmlns:ns1="http://xml.apache.org/axis/">myhostname</ns1:hostname> </detail> </soapenv:Fault> </soapenv:Body>
... in other words, this did not result in a SOAP error.
I tried a lot of other things and I got pretty stuck. So can someone tell me (ideally, an example) how to return a SOAP error response with content that I can specify in my environment?
I am not attached to using Axis (but I have more experience with this than with anything else). If you are offering an alternative, please note that I need you to call another (authenticated) web service in the web service method, and I managed to get this to work in Axis1.4 ...
source share