WCF SOAP service, single wsdl, empty namespace in soap:fault, not WS-I compliant, BP2019

803 Views Asked by At

When coding a SOAP service in C#, running it and then retrieving the WSDL from the service with ?singlewsdl option, the generated WSDL has an empty namespace attribute in the element, spoiling WSI compliance (checked with SoapUI) and resulting in error code BP2019, indicating an illegal namespace in the soap fault.

The service method is in a base interface, from which the services derive their own interfaces.

Definition is in a service interface:

[OperationContract( 
    Action = "http://mynamespace.com/services/2014/06/23/MyBaseContract/GetInterfaceVersionRequest", 
    ReplyAction = "http://mynamespace.com/services/2014/06/23/MyBaseContract/GetInterfaceVersionResponse" )]
[FaultContract(typeof(string), Name="NonsenseFault")]
string GetInterfaceVersion();

The WSDL generated by the service with ?singlewsdl contains an empty namespace attribute:

<wsdl:operation name="GetInterfaceVersion">
    <soap:operation soapAction="http://mynamespace.com/services/2014/06/23/MyBaseContract/GetInterfaceVersionRequest" style="document"/>
    <wsdl:input>
        <soap:body use="literal"/>
    </wsdl:input>
    <wsdl:output>
        <soap:body use="literal"/>
    </wsdl:output>
    <wsdl:fault name="NonsenseFault">
        <soap:fault use="literal" name="NonsenseFault" namespace=""/> <!-- spoils WS-I compliance! -->
    </wsdl:fault>
</wsdl:operation>

According to WS-I rules, the soap:fault element must not have a namespace attribute at all.

Can I do anything about this?

1

There are 1 best solutions below

3
On

You may be able to solve the issue by setting the FaultContract attribute Namespace property.

[FaultContract(typeof(string), Name="NonsenseFault", Namespace="http://my.nonsense.fault")]

http://msdn.microsoft.com/en-us/library/system.servicemodel.faultcontractattribute(v=vs.110).aspx