No -- this fault isn't interoperable because you have not defined it
properly in your WSDL.
You didn't provide us with the element definition of "tns1:fault". My
assumption, though, is that it's defined as follows:
<element name="fault" type="MyDetailedException"/>
But -- it appears that your fault detail contains two elements:
<ns1:fault> and <ns2:exceptionName>. There are two problems with that:
1- Your WSDL message definition doesn't describe the <ns2:exceptionName>
element. (To produce the fault message you describe, you would need to
define two message parts.)
2- A fault message should have only one part. If you want to return both
elements in your detail, they should be defined as a sequence of elements
within a single wrapper element.
What you need to do is define a single element which will be the child of
the <detail> element. This single element should be defined as a sequence
containing the <fault> element and the <exceptionName> element, e.g.,
<element name=faultDetail>
<complexType>
<sequence>
<element ref="tns1:fault"/>
<element ref="tns2:exceptionName"/>
</sequence>
</complexType>
</element>
And your message description should look like this:
<wsdl:message name="MyDetailedException">
<wsdl:part element="tns0:faultDetail" name="fault"/>
</wsdl:message>
The fault response should look like this (notice the faultDetail wrapper
element):
----- BEGIN FAULT RESPONSE ----
<?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>
<soapenv:Fault>
<faultcode>soapenv:Server.generalException</faultcode>
<faultstring></faultstring>
<detail>
<ns0:faultDetail xmlns:ns0="urn:FaultWrapper">
<ns1:fault xmlns:ns1="urn:MyNamespace">
<ns1:majorcode>1</ns1:majorcode>
<ns1:minorcode>2</ns1:minorcode>
</ns1:fault>
<ns2:exceptionName
xmlns:ns2="http://xml.apache.org/axis/">
com.example.MyDetailedException
</ns2:exceptionName>
</faultDetail>
</detail>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
----- END FAULT RESPONSE ----
Regards,
Anne
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Monday, September 27, 2004 11:25 PM
To: [EMAIL PROTECTED]
Subject: Is this fault interoperable?
I've included a fault response and excerpts from the WSDL
below. Will .NET and other implementations understand
this fault? If not, what do I need to do to get something
that most implementations will understand?
Note that the faultstring in the response below is empty.
However, I'll provide a human-understandable faultstring
using the following technique:
MyServiceBindingImpl {
doSomething() {
try {
// code that does the actual work
}
catch ( MyNonAxisSpecificException e ) {
throw new MyDetailedException( e );
}
}
}
MyNonAxisSpecificException will be very similar to an
AxisFault, but it won't be Axis-specific.
MyDetailedException was created by Axis, and it extends
MyBaseException which in turn extends AxisFault. A new
constructor (or similar) will be added to the axis-
generated MyDetailedException code which will take a
MyNonAxisSpecificException and fill out the various
fields, including faultstring.
----- BEGIN FAULT RESPONSE ----
<?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>
<soapenv:Fault>
<faultcode>soapenv:Server.generalException</faultcode>
<faultstring></faultstring>
<detail>
<ns1:fault xmlns:ns1="urn:MyNamespace">
<ns1:majorcode>1</ns1:majorcode>
<ns1:minorcode>2</ns1:minorcode>
</ns1:fault>
<ns2:exceptionName
xmlns:ns2="http://xml.apache.org/axis/">com.example.MyDet
ailedException</ns2:exceptionName>
</detail>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
----- END FAULT RESPONSE ----
----- BEGIN WSDL EXCERPT ----
<wsdl:types>
<complexType name="MyBaseException">
<sequence>
<element name="majorcode" type="xsd:int"/>
<element name="minorcode" type="xsd:int"/>
</sequence>
</complexType>
</wsdl:types>
<complexType name="MyDetailedException">
<complexContent>
<extension base="tns1:MyBaseException">
<sequence/>
</extension>
</complexContent>
</complexType>
<wsdl:message name="MyDetailedException">
<wsdl:part element="tns1:fault" name="fault"/>
</wsdl:message>
<wsdl:portType name="MyServicePortType">
<wsdl:operation name="doSomething" parameterOrder="">
<wsdl:input message="impl:doSomethingRequest"
name="doSomethingRequest"/>
<wsdl:output message="impl:doSomethingResponse"
name="doSomethingResponse"/>
<wsdl:fault message="impl:MyDetailedException"
name="MyDetailedException"/>
</wsdl:operation>
<wsdl:binding name="MyServiceSOAPPortSoapBinding"
type="impl:MyServicePortType">
<wsdlsoap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="doSomething">
<wsdlsoap:operation soapAction="doSomething"/>
<wsdl:input name="doSomethingRequest">
<wsdlsoap:body namespace="MyNamespace" use="literal"/>
</wsdl:input>
<wsdl:output name="doSomethingResponse">
<wsdlsoap:body namespace="MyNamespace" use="literal"/>
</wsdl:output>
<wsdl:fault name="MyDetailedException">
<wsdlsoap:fault use="literal"/>
</wsdl:fault>
</wsdl:operation>
----- END WSDL EXCERPT ----