Web service client receiving generic FaultException rather than FaultException<T>

Posted by Junto on Stack Overflow See other posts from Stack Overflow or by Junto
Published on 2010-05-05T09:12:48Z Indexed on 2010/05/05 9:18 UTC
Read the original article Hit count: 222

Filed under:
|
|

I am connecting to a Java Axis2 web service using a .NET web service client. The client itself targets the .NET 3.5 framework. The application that wraps the client DLL is 2.0. I'm not sure if that has any bearing.

I have been given the WSDL and XSDs by email. From those I have built my proxy class using svcutil. Although I am able to successfully send messages, I am unable to pick up the correct faults when something goes wrong. In the example below, errors are always being picked up by the generic FaultException.

catch (FaultException<InvoiceErrorType> fex)
{
    OnLog(enLogLevel.ERROR, fex.Detail.ErrorDescription);
}
catch (FaultException gfex)
{
    OnLog(enLogLevel.ERROR, gfex.Message);
}

The proxy client appears to have the appropriate attributes for the FaultContract:

// CODEGEN: Generating message contract since the operation SendInvoiceProvider_Prod is neither RPC nor document wrapped.
[OperationContractAttribute(Action = "https://private/SendInvoiceProvider", ReplyAction = "*")]
[FaultContractAttribute(typeof(InvoiceErrorType), Action = "https://private/SendInvoiceProvider", Name = "InvoiceError", Namespace = "urn:company:schema:entities:base")]
[XmlSerializerFormatAttribute(SupportFaults = true)]
[ServiceKnownTypeAttribute(typeof(ItemDetail))]
[ServiceKnownTypeAttribute(typeof(Supplier))]
OutboundComponent.SendInvoiceProviderResponse SendInvoiceProvider_Prod(OutboundComponent.SendInvoiceProvider_Request request);

I have enabled tracing and I can see the content of the fault coming back, but .NET is not recognizing it as an InvoiceError. The SOAP fault in full is:

<soapenv:Fault>
    <faultcode xmlns="">soapenv:Client</faultcode>
    <faultstring xmlns="">Message found to be invalid</faultstring>
    <faultactor xmlns="">urn:SendInvoiceProvider</faultactor>
    <detail xmlns="">
        <InvoiceError xmlns="urn:company:schema:entities:common:invoiceerror:v01">
                <ErrorID>100040</ErrorID>
                <ErrorType>UNEXPECTED</ErrorType>
                <ErrorDescription>&lt;![CDATA[&lt;error xmlns="urn:company:schema:errordetail:v01"&gt;&lt;errorCode&gt;1000&lt;/errorCode&gt;&lt;highestSeverity&gt;8&lt;/highestSeverity&gt;&lt;errorDetails count="1"&gt;&lt;errorDetail&gt;&lt;errorType&gt;1&lt;/errorType&gt;&lt;errorSeverity&gt;8&lt;/errorSeverity&gt;&lt;errorDescription&gt;cvc-complex-type.2.4.a: Invalid content was found starting with element 'CompanyName'. One of '{"urn:company:schema:sendinvoice:rq:v01":RoleType}' is expected.&lt;/errorDescription&gt;&lt;errorNamespace&gt;urn:company:schema:sendinvoice:rq:v01&lt;/errorNamespace&gt;&lt;errorNode&gt;CompanyName&lt;/errorNode&gt;&lt;errorLine&gt;1&lt;/errorLine&gt;&lt;errorColumn&gt;2556&lt;/errorColumn&gt;&lt;errorXPath/&gt;&lt;errorSource/&gt;&lt;/errorDetail&gt;&lt;/errorDetails&gt;&lt;/error&gt;]]&gt;</ErrorDescription>
                <TimeStamp>2010-05-04T21:12:10Z</TimeStamp>
        </InvoiceError>
    </detail>
</soapenv:Fault>

I have noticed the namespace defined on the error:

<InvoiceError xmlns="urn:company:schema:entities:common:invoiceerror:v01">

This is nowhere to be seen in the generated proxy class, nor in the WSDLs. The interface WSDL defines the error schema namespace as such:

<xs:import namespace="urn:company:schema:entities:base" schemaLocation="InvoiceError.xsd"/>

Could this be the reason why the .NET client is not able to parse the typed Fault Exception correctly?

I have no control over the web service itself. I see no reason why .NET can't talk to a Java Axis2 web service. This user had a similar issue, but the reason for his problem cannot be the same as mine, since I can see the fault detail in the trace: http://stackoverflow.com/questions/864800/does-wcf-faultexceptiont-support-interop-with-a-java-web-service-fault

Any help would be gratefully received.

© Stack Overflow or respective owner

Related posts about webservice-client

Related posts about axis2