Note that there are some explanatory texts on larger screens.

plurals
  1. PODoes WCF FaultException<T> support interop with a Java web service Fault
    primarykey
    data
    text
    <p>I have written a java axis2 1.4.1 web service and .net 3.5 WCF client and I am trying to catch the wsdl faults thrown. </p> <p>Unlike .net 2.0 the .net 3.5 claims to support <code>wsdl:fault</code> and the service reference wizard does generate all the correct fault classes in the client proxy. But when I try to catch a fault it doesn't seem to correctly serialise so that I can only <code>catch (FaultException ex)</code> and not the type I actually threw using <code>FaultException&lt;T&gt;</code></p> <p>I had a look inside my reference.cs I can see wizard has added correct <code>FaultContract</code> to the my opeation.</p> <pre><code>[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")] [System.ServiceModel.ServiceContractAttribute(Namespace="http://www.mycomp.com/wsdl/Foo", ConfigurationName="FooServiceProxy.Foo")] public interface Foo { [System.ServiceModel.OperationContractAttribute(Action="http://www.mycomp.com/Foo/list", ReplyAction="*")] [System.ServiceModel.FaultContractAttribute(typeof(TestWsdlFaultsApp.FooServiceProxy.SimpleFault), Action="http://www.mycomp.com/Foo/list", Name="simpleFault")] [System.ServiceModel.XmlSerializerFormatAttribute()] TestWsdlFaultsApp.FooServiceProxy.listResponse list(TestWsdlFaultsApp.FooServiceProxy.listRequest request); } </code></pre> <p>Is there something else I need to do in .net to get this to work? or does WCF only support custom wsdl faults from a .net web service ?</p> <p>Heres my wsdl </p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;?xml-stylesheet type="text/xsl" href="wsdl-viewer.xsl"?&gt; &lt;wsdl:definitions name="FooImplDefinitions" targetNamespace="http://www.mycomp.com/wsdl/Foo" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.mycomp.com/wsdl/Foo" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt; &lt;!-- TYPES --&gt; &lt;wsdl:types&gt; &lt;xs:schema targetNamespace="http://www.mycomp.com/wsdl/Foo" elementFormDefault="qualified" attributeFormDefault="unqualified" xmlns:security="http://www.mycomp.com/xsd/types/Security"&gt; &lt;!-- IMPORTS --&gt; &lt;xs:import namespace="http://www.mycomp.com/xsd/types/Foo" schemaLocation="Foo.xsd" /&gt; &lt;xs:import namespace="http://www.mycomp.com/xsd/types/Security" schemaLocation="Security.xsd" /&gt; &lt;!-- HEADER ELEMENTS --&gt; &lt;xs:element name="identity" type="security:TrustedIdentity" /&gt; &lt;!-- REQUEST/RESPONSE ELEMENTS --&gt; &lt;xs:element name="listRequest"&gt; &lt;xs:complexType&gt; &lt;xs:sequence&gt; &lt;xs:element name="action" type="xs:string" /&gt; &lt;/xs:sequence&gt; &lt;/xs:complexType&gt; &lt;/xs:element&gt; &lt;xs:element name="listResponse"&gt; &lt;xs:complexType&gt; &lt;xs:sequence&gt; &lt;xs:element name="stuff" type="xs:string" /&gt; &lt;/xs:sequence&gt; &lt;/xs:complexType&gt; &lt;/xs:element&gt; &lt;!-- FAULT TYPES --&gt; &lt;xs:complexType name="SimpleFault"&gt; &lt;xs:sequence&gt; &lt;xs:element name="reason" type="xs:string"/&gt; &lt;/xs:sequence&gt; &lt;/xs:complexType&gt; &lt;!-- FAULT ELEMENTS --&gt; &lt;xs:element name="simpleFault" type="tns:SimpleFault"/&gt; &lt;/xs:schema&gt; &lt;/wsdl:types&gt; &lt;!-- MESSAGES --&gt; &lt;wsdl:message name="listRequest"&gt; &lt;wsdl:part element="tns:listRequest" name="parameters" /&gt; &lt;wsdl:part element="tns:identity" name="header" /&gt; &lt;/wsdl:message&gt; &lt;wsdl:message name="listResponse"&gt; &lt;wsdl:part element="tns:listResponse" name="return" /&gt; &lt;/wsdl:message&gt; &lt;wsdl:message name="simpleException"&gt; &lt;wsdl:part element="tns:simpleFault" name="fault"/&gt; &lt;/wsdl:message&gt; &lt;!-- PORT TYPES --&gt; &lt;wsdl:portType name="Foo"&gt; &lt;wsdl:operation name="list"&gt; &lt;wsdl:input message="tns:listRequest" /&gt; &lt;wsdl:output message="tns:listResponse" /&gt; &lt;wsdl:fault name="simpleFault" message="tns:simpleException" /&gt; &lt;/wsdl:operation&gt; &lt;/wsdl:portType&gt; &lt;!-- BINDINGS --&gt; &lt;wsdl:binding name="FooBinding" type="tns:Foo"&gt; &lt;soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" /&gt; &lt;wsdl:operation name="list"&gt; &lt;soap:operation soapAction="http://www.mycomp.com/Foo/list" /&gt; &lt;wsdl:input&gt; &lt;soap:header message="tns:listRequest" part="header" use="literal" /&gt; &lt;soap:body parts="parameters" use="literal" /&gt; &lt;/wsdl:input&gt; &lt;wsdl:output&gt; &lt;soap:body use="literal" /&gt; &lt;/wsdl:output&gt; &lt;wsdl:fault name="simpleFault"&gt; &lt;soap:fault name="simpleFault" use="literal" /&gt; &lt;/wsdl:fault&gt; &lt;/wsdl:operation&gt; &lt;/wsdl:binding&gt; &lt;!-- SERVICES --&gt; &lt;wsdl:service name="FooServiceImpl"&gt; &lt;wsdl:port name="FooPort" binding="tns:FooBinding"&gt; &lt;soap:address location="http://localhost:9001/Foo/FooServiceImpl" /&gt; &lt;/wsdl:port&gt; &lt;/wsdl:service&gt; &lt;/wsdl:definitions&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload