SOAP Fault uses Types instead of Tag names RRS feed

  • Question

  • User-1958195367 posted


    First of all, here is my setup:

    - .Net 4.0

    - WCF service, with basicHttpBinding (soap 1.1)

    - The web service 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 : the root tag in the detail of the fault is using a type name, and not a tag name. 

    Here is the WSDL definition (extracts), to understand the situation better:

    <wsdl:message name="CreateScheduledWorkRequest">
    		<wsdl:part name="parameters" element="root:CreateScheduledWork"/>
    	<wsdl:message name="CreateScheduledWorkResponse">
    		<wsdl:part name="parameters" element="root:CreateScheduledWorkResponse"/>
    	<wsdl:message name="CreateScheduledWorkFault">
    		<wsdl:part name="parameters" element="root:CreateScheduledWorkFault"/>
    <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: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:output name="CreateScheduledWorkResponse">
    				<wsdlsoap:body use="literal"/>
    			<wsdl:fault name="CreateScheduledWorkFault">
    				<wsdlsoap:fault name="CreateScheduledWorkFault" use="literal"/>

    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...

    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.


    Wednesday, January 9, 2013 5:38 AM

All replies

  • User-1000095884 posted


    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...

    When you use UseSerializerForFaults, it specifies that the XmlSerializer should be used for reading and writing faults, instead of the default Datacontractserializer, so please make sure you are using XmlSerializer, it uses Datacontractserializer by default.

    Best Regards.<!--EndFragment-->

    Thursday, January 10, 2013 4:25 AM
  • User-1958195367 posted


    Thanks for your reply.

    Yes, in the interface definition, I specified the use of XmlSerializer :

    [ServiceContract(Namespace = "http://www.orange.com/MACHX/Interfaces/ManageScheduledWork/ScheduledWorkManagement/v1")]
    [XmlSerializerFormat(SupportFaults = true)]
    public interface IManageScheduledWork
        [OperationContract(Action = "http://www.orange.com/MACHX/Interfaces/ManageScheduledWork/ScheduledWorkManagement/v1/CreateScheduledWork")]
        CreateScheduledWorkResponse CreateScheduledWork(CreateScheduledWorkRequest request);

    I also tried to specify the Fault contract :


    But then again, I can't use CreateScheduledWorkFault in the type.

    Best Regards

    Thursday, January 10, 2013 5:10 AM
  • User-1958195367 posted

    Quick question : is there another way to force the use of the XmlSerializer?

    Or is it a WSDL/XSD issue that prevents from generating the correct types?

    Thanks for your help.

    Tuesday, January 15, 2013 4:56 AM
  • User-1958195367 posted


    I managed to get the correct type (I modified directly in the generated class; I know it's bad, but there is no other choice in my situation for the moment).

    There is an other issue now, as the main tag is not recognized as being a root on the client side.

    Here is what I send back (in the <detail> tag of the fault):


    Here is what is expected:


    FYI, the system I am communicating with is an EAI middleware (using Java WebMethods I think).

    Actually, they receive raw XML like so:

    <CreateScheduledWorkFault xmlns="http://www.orange.com/MACHX/Interfaces/ManageScheduledWork/ScheduledWorkManagement/v1/root">

    Therefore, I modified the definition in my interface, from :




    But when I send the fault to the EAI, the "/root" part is removed, giving:

    <CreateScheduledWorkFault xmlns="http://www.orange.com/MACHX/Interfaces/ManageScheduledWork/ScheduledWorkManagement/v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

    ...does anyone have an idea why this is happening?

    FYI, when sending a normal Response (so no faultExceptions have been thrown), they receive the following tag:

    <CreateScheduledWorkResponse xmlns="http://www.orange.com/MACHX/Interfaces/ManageScheduledWork/ScheduledWorkManagement/v1/root">

    Thanks for your help.

    Thursday, January 24, 2013 5:30 AM