User Services Exceptions Thrown as AxisFault

We have an Axis2 client reading from the SOAP web service; The problem arose when new client stub classes were generated using WSDL2JAVA and their packages were renamed. The generation tool itself does not cause a problem, but WSDL2JAVA does not rename packages for all classes, so I need to do it myself.

Any idea on a better way to rename packages for these classes without problems? How to make string replacement in a smart way?

In some cases, the web service throws business exceptions and they are thrown directly by the calling code, but this does not happen anymore, and instead of SPECIALException, the client now catches AxisFault.

You can see the XML response below:

<?xml version='1.0' encoding='utf-8'?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> <soapenv:Body> <soapenv:Fault> <faultcode>soapenv:Server</faultcode> <faultstring>Exception message, due to business error.</faultstring> <detail> <ns2:SPECIALException xmlns:ns2="http://com.bla.com/common/exception/xsd/2008/08"> <ns2:code>7</ns2:code> <ns2:message>Exception message, due to business error.</ns2:message> </ns2:SPECIALException> </detail> </soapenv:Fault> </soapenv:Body> </soapenv:Envelope> 

Checking this in more detail, the difference is probably due to the populateFaults method in the generated Bla ServiceStub class, where class names are set as strings for later use through reflection.

+7
java soap web-services soap-client axis2
source share
1 answer

This was resolved by replacing String in all generated stub classes without changing the entire package name, so say you used '-p com.my.company.network.stubs in generation', and then to stop the packages in the 'com. bla.blo.bli ", do not rename to" com.my.company.network.stubs.bli ", but do so before" com.my.company.network.stubs.bla.blo.bli

+1
source share

All Articles