简体   繁体   中英

WCF SOAP Fault incorrect type

First of all, here is my setup:

  • .Net 4.0 ASP.Net application
  • WCF service, with basicHttpBinding (soap 1.1)
  • The reference class was generated using svcutil, with the options /useSerializerForFaults; the WSDL defines all operations, and provides links to the types.xsd and the types_fault.xsd files. FYI, the WSD and XSD files are common for many applications so I cannot modify them (unless of course there some major validation errors)

My issue stands when I send a SOAP Fault to the client : I am unable to access the correct type in the code, for the fault detail, so the client is not able to process this fault.

Here is an extract of the WSDL for your understanding:

<wsdl:message name="CreateScheduledWorkRequest">
            <wsdl:part name="parameters" element="root:CreateScheduledWork"/>
    </wsdl:message>
    <wsdl:message name="CreateScheduledWorkResponse">
            <wsdl:part name="parameters" element="root:CreateScheduledWorkResponse"/>
    </wsdl:message>
    <wsdl:message name="CreateScheduledWorkFault">
            <wsdl:part name="parameters" element="root:CreateScheduledWorkFault"/>
    </wsdl:message>

<wsdl:portType name="ManageScheduledWorkScheduledWorkManagement">
<wsdl:operation name="CreateScheduledWork">
                    <wsdl:input name="CreateScheduledWorkRequest" message="intf:CreateScheduledWorkRequest"/>
                    <wsdl:output name="CreateScheduledWorkResponse" message="intf:CreateScheduledWorkResponse"/>
                    <wsdl:fault name="CreateScheduledWorkFault" message="intf:CreateScheduledWorkFault"/>
            </wsdl:operation>
</wsdl:portType>

<wsdl:binding name="ManageScheduledWorkScheduledWorkManagementBinding"   type="intf:ManageScheduledWorkScheduledWorkManagement">
            <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
            <wsdl:operation name="CreateScheduledWork">
                    <wsdlsoap:operation soapAction="http://www.orange.com/MACHX/Interfaces/ManageScheduledWork/ScheduledWorkManagement/v1/CreateScheduledWork"/>
                    <wsdl:input name="CreateScheduledWorkRequest">
                            <wsdlsoap:body use="literal"/>
                    </wsdl:input>
                    <wsdl:output name="CreateScheduledWorkResponse">
                            <wsdlsoap:body use="literal"/>
                    </wsdl:output>
                    <wsdl:fault name="CreateScheduledWorkFault">
                            <wsdlsoap:fault name="CreateScheduledWorkFault" use="literal"/>
                    </wsdl:fault>
            </wsdl:operation>
</wsdl:binding>

So for example, when I send a Response back (no errors occurred), I can use the CreateScheduledWorkResponse element, and fill it correctly; but when a FaultException occurs, I'm only able to send back a CreateScheduledWorkFaultMessage (and not a CreateScheduledWorkFault). And the client cannot handle this tag...

In other words, the CreateScheduledWorkFault type is not available in the code.

--> I suspect that there is something wrong when generating the code from the WSDL and XSD using svcutil , as I am not able to access the desired type in the code.

I use svcutil this way:

svcutil /useSerializerForFaults CSW.wsdl CSW.xsd CSW_Fault.xsd

Thanks for your help, and don't hesitate if you need more details.

Boris

My solution was to modify directly the type in the generated class... it's bad, but in my situation it was the only choice I had (normally I should never regenerate it as the WSDL will never change).

Now I have another issue, but it's more namespace related, so I will open a new question for that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM