Hello, I try to use custom exceptions. The service is written in C++ and the client is Java. When the service throws a custom exception, the client only gets an AxisFault not the custom exception (TestException). I didn't change anything in the client's stubs.
Does anyone understand whats wrong? The service-response or the client-side processing? Below the client-code, the exception, the request, the response, the AxisFault and the WSDL. I hope anyone can help! Thanks, Stephan Ant-section to build the client: -------------------------------- <axis-wsdl2java url="http://localhost/axis/TestService?wsdl" output="${src}" /> The test-client: ---------------- package at.apa.webservices.test; import java.net.URL; import org.apache.axis.AxisFault; public class Client { public static void main(String[] args) { try { TestServiceLocator locator = new TestServiceLocator(); Test test = locator.getTest(new URL("http://localhost:12345/axis/TestService")); int[] result = test.testFixedArray(3); System.out.println("done"); } catch (TestException e) { e.printStackTrace(System.out); // never reached } catch (Throwable e) { e.printStackTrace(System.err); } } } The custom exception (without stub-additions): ---------------------------------------------- package at.apa.webservices.test; public class TestException extends Exception { private String error; public final String getError() { return error; } public final void setError(String error) { this.error = error; } } The request: ------------ POST /axis/TestService HTTP/1.0 Content-Type: text/xml; charset=utf-8 Accept: application/soap+xml, application/dime, multipart/related, text/* User-Agent: Axis/1.2.1 Host: localhost:12345 Cache-Control: no-cache Pragma: no-cache SOAPAction: "Test#testFixedArray" Content-Length: 345 <?xml version="1.0" encoding="UTF-8"?><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><tes tFixedArray xmlns="http://test.webservices.apa.at"><in0>3</in0></testFixedArray></so apenv:Body></soapenv:Envelope> The response: ------------- HTTP/1.1 200 OK Date: Fri, 08 Jul 2005 09:17:15 GMT Server: Apache/1.3.27 (Unix) Connection: close Content-Type: text/xml <?xml version='1.0' encoding='utf-8' ?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <SOAP-ENV:Body> <SOAP-ENV:Fault> <faultcode>AxisC++ Faultcode</faultcode> <faultstring>Custom Out of bound exception</faultstring> <faultactor>server name:listen port</faultactor> <detail><TestException><ns1:error>JUHU</ns1:error> </TestException> </detail> </SOAP-ENV:Fault> </SOAP-ENV:Body> </SOAP-ENV:Envelope> AxisFault: ---------- AxisFault faultCode: AxisC++ Faultcode faultSubcode: faultString: Custom Out of bound exception faultActor: server name:listen port faultNode: faultDetail: {}TestException:<error>JUHU</error> Custom Out of bound exception at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.ja va:221) at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.jav a:128) at org.apache.axis.encoding.DeserializationContext.endElement(Deserializati onContext.java:1087) at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1712) at org.apache.crimson.parser.Parser2.content(Parser2.java:1963) at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1691) at org.apache.crimson.parser.Parser2.content(Parser2.java:1963) at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1691) at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:667) at org.apache.crimson.parser.Parser2.parse(Parser2.java:337) at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:448) at javax.xml.parsers.SAXParser.parse(SAXParser.java:345) at org.apache.axis.encoding.DeserializationContext.parse(DeserializationCon text.java:227) at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696) at org.apache.axis.Message.getSOAPEnvelope(Message.java:424) at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstan dChecker.java:62) at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206) at org.apache.axis.client.Call.invokeEngine(Call.java:2765) at org.apache.axis.client.Call.invoke(Call.java:2748) at org.apache.axis.client.Call.invoke(Call.java:2424) at org.apache.axis.client.Call.invoke(Call.java:2347) at org.apache.axis.client.Call.invoke(Call.java:1804) at at.apa.webservices.test.TestServiceSoapBindingStub.testFixedArray(TestSe rviceSoapBindingStub.java:286) at at.apa.webservices.test.Client.main(Client.java:12) The WSDL: --------- <?xml version="1.0" encoding="UTF-8"?> <wsdl:definitions targetNamespace="http://test.webservices.apa.at" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://test.webservices.apa.at-impl" xmlns:intf="http://test.webservices.apa.at" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <wsdl:types> <schema elementFormDefault="qualified" targetNamespace="http://test.webservices.apa.at" xmlns="http://www.w3.org/2001/XMLSchema"> <element name="testFixedArray"> <complexType> <sequence> <element name="in0" type="xsd:int"/> </sequence> </complexType> </element> <element name="testFixedArrayResponse"> <complexType> <sequence> <element name="testFixedArrayReturn" type="intf:MEFARRAYFIXED"/> </sequence> </complexType> </element> <complexType name="TestException"> <sequence> <element name="error" nillable="true" type="xsd:string"/> </sequence> </complexType> <element name="fault" type="intf:TestException"/> </schema> </wsdl:types> <wsdl:message name="testFixedArrayRequest"> <wsdl:part element="intf:testFixedArray" name="parameters"/> </wsdl:message> <wsdl:message name="TestException"> <wsdl:part element="intf:fault" name="fault"/> </wsdl:message> <wsdl:message name="testFixedArrayResponse"> <wsdl:part element="intf:testFixedArrayResponse" name="parameters"/> </wsdl:message> <wsdl:portType name="Test"> <wsdl:operation name="testFixedArray"> <wsdl:input message="intf:testFixedArrayRequest" name="testFixedArrayRequest"/> <wsdl:output message="intf:testFixedArrayResponse" name="testFixedArrayResponse"/> <wsdl:fault message="intf:TestException" name="TestException"/> </wsdl:operation> </wsdl:portType> <wsdl:binding name="TestServiceSoapBinding" type="intf:Test"> <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> <wsdl:operation name="testFixedArray"> <wsdlsoap:operation soapAction="Test#testFixedArray"/> <wsdl:input name="testFixedArrayRequest"> <wsdlsoap:body use="literal"/> </wsdl:input> <wsdl:output name="testFixedArrayResponse"> <wsdlsoap:body use="literal"/> </wsdl:output> <wsdl:fault name="TestException"> <wsdlsoap:fault name="TestException" use="literal"/> </wsdl:fault> </wsdl:operation> </wsdl:binding> <wsdl:service name="TestService"> <wsdl:port binding="intf:TestServiceSoapBinding" name="Test"> <wsdlsoap:address location="http://localhost/axis/TestService"/> </wsdl:port> </wsdl:service> </wsdl:definitions>
