1

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?

Erik Hart
  • 1,114
  • 1
  • 13
  • 28
  • Does it do the same thing with `?wsdl`? – John Saunders Jan 12 '15 at 15:58
  • No, it doesn't with ?wsdl, but I want ?singlewsdl to have just one file and not mess around with various xsds. Btw, when I create a project in SoapUI from only ?wsdl, it doesn't create any method calls. – Erik Hart Jan 12 '15 at 16:11
  • Something odd going on there. You should try to reproduce the problem with a simpler case. In particular, I wonder if it does this for all fault contracts. I'm concerned about the difference between `?wsdl` and `?singleWsdl`. – John Saunders Jan 12 '15 at 16:17

1 Answers1

0

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

Seymour
  • 7,043
  • 12
  • 44
  • 51
  • It's supposed to not have a namespace at all, according to WS-I spec. And when I specify a namespace, the namespace attribute in soap:fault is still empty. – Erik Hart Jan 12 '15 at 13:30
  • You may be able to save the generated wsdl, tweak the namespace, import into a test project using a “contract first” approach and then look at the difference between your original code and the autogenerated code. – Seymour Jan 12 '15 at 14:06
  • I wanted to use a code-first approach, with service definitions only through the interface and attributes, without editing a WSDL and then creating a contract from it. It is in fact easy to manually remove the empty Namespace attribute and get a WS-I compliant WSDL, but that's not what I wanted. – Erik Hart Jan 12 '15 at 15:17