You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Kamal Advani <ka...@gmail.com> on 2007/07/10 04:07:04 UTC

WSDL Fault type not being deserialized properly

Hi all,

We're using Axis 1.4.  The service we're attempting to connect to throws
various faults defined in the WSDL. All the faults are properly generated as
Java classes. Currently, we have a test service (also generated by Axis)
that simulates these faults by throwing them on specific inputs to the
service. Here's an extract of the fault definitions in the WSDL:

----------------------
            <xsd:complexType name="FaultType">
                <xsd:sequence>
                    <xsd:element type="xsd:int" name="FaultID"/>
                    <xsd:element type="xsd:string" name="MessageText"/>
                    <xsd:element name="Severity">
                        <xsd:simpleType>
                            <xsd:restriction base="xsd:string">
                                <xsd:enumeration value="Warning"/>
                                <xsd:enumeration value="Error"/>
                            </xsd:restriction>
                        </xsd:simpleType>
                    </xsd:element>
                </xsd:sequence>
            </xsd:complexType>
            <complexType name="processELFDataFormatFaultType">
                <complexContent>
                    <extension base="impl:FaultType"/>
                </complexContent>
            </complexType>
            ... <!-- other specific Faults -->
----------------------

The generated FaultType class has the following constructor:


----------------------
    public FaultType(
           int faultID,
           java.lang.String messageText,
           au.gov.vic.sro.conveyancing.ws.lodgement.v1_1.FaultTypeSeverityseverity)
{
        this.faultID = faultID;
        this.messageText = messageText;
        this.severity = severity;
    }
----------------------

The test service gets invoked, checks the input parameter, and does say:

----------------------
throw new  ProcessELFDataFormatFaultType(1, "Data Format Fault",
FaultTypeSeverity.fromValue(FaultTypeSeverity._Error));
----------------------


The invoker is then able to catch a generic FaultType (which extends
AxisFault) exception, however the details are not mapped in the way it was
thrown, here's a trace on the client/invoker's side:

----------------------
AxisFault
faultCode: {
http://schemas.xmlsoap.org/soap/envelope/}Server.generalException
faultSubcode:
faultString:
faultActor:
faultNode:
faultDetail:
    {}au.gov.vic.sro.conveyancing.ws.lodgement.v1_1.FaultType:<ns1:FaultID
xmlns:ns1="
http://www.e-business.sro.vic.gov.au/ConveyancingServices/services/v1.1">1</ns1:FaultID><ns2:MessageText
xmlns:ns2="
http://www.e-business.sro.vic.gov.au/ConveyancingServices/services/v1.1">Data
Format Fault</ns2:MessageText><ns3:Severity xmlns:ns3="
http://www.e-business.sro.vic.gov.au/ConveyancingServices/services/v1.1
">Error</ns3:Severity>
    {
http://xml.apache.org/axis/}exceptionName:au.gov.vic.sro.conveyancing.ws.lodgement.v1_1.ProcessELFDataFormatFaultType
    {http://xml.apache.org/axis/}hostname:B003169

    at java.lang.Class.newInstanceImpl(Native Method)
    at java.lang.Class.newInstance(Class.java:1263)
    at org.apache.axis.message.SOAPFaultBuilder.createFault(
SOAPFaultBuilder.java:182)
    at org.apache.axis.message.SOAPFaultBuilder.endElement(
SOAPFaultBuilder.java:129)
    at org.apache.axis.encoding.DeserializationContext.endElement(
DeserializationContext.java:1087)
    at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown
Source)
    at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown
Source)
    at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown
Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown
Source)
----------------------


In particular I am interested in fault.getMessageText() ("Data Format Fault"
in the example above) - however this returns null in the mapped (/caught)
fault - instead all the necessary FaultType details are left as nodes in
fault.getFaultDetails().

Any particular configuration detail I am missing?

If this is expected behaviour, is there a generic/portable/idiomatic way to
deserialize the nodes into a FaultType object to retrieve it's message text?

Please let me know if you need more information.

Thanks.


Regards,
Kamal

Re: WSDL Fault type not being deserialized properly

Posted by Kamal Advani <ka...@gmail.com>.
Hello,

An update on this, it turns out that when we invoke actual service (not sure
what the external party's webservices implementation is) - the mapping from
the XML to the FaultType happens correctly in the invoking code, here's the
trace:

---------------------
                                 AxisFault
 faultCode: {
http://www.e-business.sro.vic.gov.au/ConveyancingServices/services/v1.1}processELFSystemFaultType
 faultSubcode:
 faultString:
au.gov.vic.sro.econvey.webservice.elf.ProcessELFSystemFaultType
 faultActor:
 faultNode:
 faultDetail:
    {
http://www.e-business.sro.vic.gov.au/ConveyancingServices/services/v1.1}processELFSystemFault:<p252:FaultID>3</p252:FaultID><p252:MessageText>The
system sustained a fatal error when processing the
request</p252:MessageText><p252:Severity>Error</p252:Severity>
---------------------

Looks like some namespace issue - this fault has
{<namespace>}<faultname>:<detail> whereas the fault caught below just has
empty braces {}<faultname>:<detail>.

In the above, caughtFault.getMessageText() gives us the correct message text
("The system sustained a fatal error...").

So it looks like the test service is either not configured correctly or is
throwing the fault incorrectly...

Thanks.



On 7/10/07, Kamal Advani <ka...@gmail.com> wrote:
>
> Hi all,
>
> We're using Axis 1.4.  The service we're attempting to connect to throws
> various faults defined in the WSDL. All the faults are properly generated as
> Java classes. Currently, we have a test service (also generated by Axis)
> that simulates these faults by throwing them on specific inputs to the
> service. Here's an extract of the fault definitions in the WSDL:

----------------------
>             <xsd:complexType name="FaultType">
>                 <xsd:sequence>
>                     <xsd:element type="xsd:int" name="FaultID"/>
>                     <xsd:element type="xsd:string" name="MessageText"/>
>                     <xsd:element name="Severity">
>                         <xsd:simpleType>
>                             <xsd:restriction base="xsd:string">
>                                 <xsd:enumeration value="Warning"/>
>                                 <xsd:enumeration value="Error"/>
>                             </xsd:restriction>
>                         </xsd:simpleType>
>                     </xsd:element>
>                 </xsd:sequence>
>             </xsd:complexType>
>             <complexType name="processELFDataFormatFaultType">
>                 <complexContent>
>                     <extension base="impl:FaultType"/>
>                 </complexContent>
>             </complexType>
>             ... <!-- other specific Faults -->
> ----------------------
>
> The generated FaultType class has the following constructor:
>
>
> ----------------------
>     public FaultType(
>            int faultID,
>            java.lang.String messageText,
>            au.gov.vic.sro.conveyancing.ws.lodgement.v1_1.FaultTypeSeverityseverity) {
>         this.faultID = faultID;
>         this.messageText = messageText;
>         this.severity = severity;
>     }
> ----------------------
>
> The test service gets invoked, checks the input parameter, and does say:
>
> ----------------------
> throw new  ProcessELFDataFormatFaultType(1, "Data Format Fault",
> FaultTypeSeverity.fromValue(FaultTypeSeverity._Error));
> ----------------------
>
>
> The invoker is then able to catch a generic FaultType (which extends
> AxisFault) exception, however the details are not mapped in the way it was
> thrown, here's a trace on the client/invoker's side:
>
> ----------------------
> AxisFault
> faultCode: {
> http://schemas.xmlsoap.org/soap/envelope/}Server.generalException<http://schemas.xmlsoap.org/soap/envelope/%7DServer.generalException>
> faultSubcode:
> faultString:
> faultActor:
> faultNode:
> faultDetail:
>     {}au.gov.vic.sro.conveyancing.ws.lodgement.v1_1.FaultType:<ns1:FaultID
> xmlns:ns1="http://www.e-business.sro.vic.gov.au/ConveyancingServices/services/v1.1">1</ns1:FaultID><ns2:MessageText
> xmlns:ns2="http://www.e-business.sro.vic.gov.au/ConveyancingServices/services/v1.1">Data
> Format Fault</ns2:MessageText><ns3:Severity xmlns:ns3="http://www.e-business.sro.vic.gov.au/ConveyancingServices/services/v1.1
> ">Error</ns3:Severity>
>     {http://xml.apache.org/axis/}exceptionName:au.gov.vic.sro.conveyancing.ws.lodgement.v1_1.ProcessELFDataFormatFaultType<http://xml.apache.org/axis/%7DexceptionName:au.gov.vic.sro.conveyancing.ws.lodgement.v1_1.ProcessELFDataFormatFaultType>
>     {http://xml.apache.org/axis/}hostname:B003169
> <http://xml.apache.org/axis/%7Dhostname:B003169>
>
>     at java.lang.Class.newInstanceImpl(Native Method)
>     at java.lang.Class.newInstance(Class.java:1263)
>     at org.apache.axis.message.SOAPFaultBuilder.createFault(
> SOAPFaultBuilder.java:182)
>     at org.apache.axis.message.SOAPFaultBuilder.endElement(
> SOAPFaultBuilder.java:129)
>     at org.apache.axis.encoding.DeserializationContext.endElement(
> DeserializationContext.java:1087)
>     at org.apache.xerces.parsers.AbstractSAXParser.endElement (Unknown
> Source)
>     at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown
> Source)
>     at
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown
> Source)
>     at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown
> Source)
> ----------------------
>
>
> In particular I am interested in fault.getMessageText() ("Data Format
> Fault" in the example above) - however this returns null in the mapped
> (/caught) fault - instead all the necessary FaultType details are left as
> nodes in fault.getFaultDetails().
>
> Any particular configuration detail I am missing?
>
> If this is expected behaviour, is there a generic/portable/idiomatic way
> to deserialize the nodes into a FaultType object to retrieve it's message
> text?
>
> Please let me know if you need more information.
>
> Thanks.
>
>
> Regards,
> Kamal
>
>
>
>
>
>
>
>
>
>