Web service client receiving generic FaultException rather than FaultException<T>
- by Junto
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><![CDATA[<error xmlns="urn:company:schema:errordetail:v01"><errorCode>1000</errorCode><highestSeverity>8</highestSeverity><errorDetails count="1"><errorDetail><errorType>1</errorType><errorSeverity>8</errorSeverity><errorDescription>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.</errorDescription><errorNamespace>urn:company:schema:sendinvoice:rq:v01</errorNamespace><errorNode>CompanyName</errorNode><errorLine>1</errorLine><errorColumn>2556</errorColumn><errorXPath/><errorSource/></errorDetail></errorDetails></error>]]></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.