Erik Hart
Erik Hart

Reputation: 1344

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

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?

Upvotes: 1

Views: 806

Answers (1)

Seymour
Seymour

Reputation: 7067

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

Upvotes: 0

Related Questions