Soap Fault namespace attribute

Oct 11, 2012 at 12:52 PM

Hi noticed that when generating WSDL that the namespace attribute is declared but empty.

This results in the WSDL not validating against WS-I Basic Profile 1.1

<operation name="Ping">
     <soap:operation soapAction="http://wscf/WS_0001_Person/v1:pingIn" style="document" />
     <input>
       <soap:body use="literal" />
       <soap:header message="import2:PingInHeader" part="parameters" use="literal" />
     </input>
     <output>
       <soap:body use="literal" />
       <soap:header message="import2:PingOutHeader" part="parameters" use="literal" />
     </output>
     <fault name="Fault">
       <soap:fault use="literal" name="Fault" namespace="" />
     </fault>
   </operation>

Any thoughts on this issue?

Jean Louis

Coordinator
Oct 17, 2012 at 12:20 PM

Hi Jean Louis.

Your observation has been reproduced and fixed in version 1.0.10

Coordinator
Oct 17, 2012 at 1:02 PM

Hi, according to the WS-I Basic Profile 1.1:

R2716 A document-literal binding in a DESCRIPTION MUST NOT have the namespace attribute specified on contained soapbind:body, soapbind:header, soapbind:headerfault and soapbind:fault elements.

In version 1.0.10 the result is not an empty namespace, but rather that it is filled out with the namespace of the fault.

     <fault name="Fault">

       <soap:fault use="literal" name="Fault" namespace="" />

     </fault>

 

Should be:

     <fault name="Fault">

       <soap:fault use="literal" name="Fault" />

     </fault>

 

The reason the namespace appears here and not on for example input or output is because the Namespace property of SoapFaultBinding is different from the Namespace property of the other classes, SoapHeaderBinding and SoapBodyBinding.

Developer
Oct 18, 2012 at 6:49 AM

Hi,

I have posted some changes regarding the namespace="" in soap:fault. Due to the different implementation of the Namespace property in SoapFaultBinding, I found doing the "fix" in regex to be the cleanest way of getting rid of namespace="".

 

Before returning from WriteInitialWsdl() I send the wsdlData to this method below:

private static string CleanFaultBindingNamespaces(string wsdlData)
        {
            const string pattern = "(?<start><soap:fault)(?<content1>.+)(?<namespace>namespace=\"\")(?<content2>.+)(?<end>/>)";
            const string replacepattern = "${start}${content1}${content2}${end}";
            return Regex.Replace(wsdlData, pattern, replacepattern, RegexOptions.Multiline);
        }

Let me explain the groups.

start = "<soap:fault"
content1 = All attributes before namespace="".
namespace = "namespace="" "
content2 = All attributes after namespace="".
end = "/>"

The replace pattern simply writes everything but the namespace group, thus getting it out of the way :)