开发者

How can I configure SOAP XML namespaces in web service client request?

I am having trouble calling a 3rd party web-service. I have not received 开发者_开发问答a SOAP fault, but am not getting a valid resultset. A colleague of mine has written a client in RPG on the OS400 and it returns a valid resultset. When comparing the RAW request in Fiddler2 for both requests, the only glaring difference I noticed was that my c# client had SOAP xml elements with xmlns="" and his did not. Is it possible to remove said empty namespace declarations? Please see the referenced SOAP request below:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
        xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <SendArchitectServiceRequest xmlns="archserver.xsd.dataflux.com">
            <serviceName xmlns="">AddressVerify.dmc</serviceName>
            <fieldDefinitions xmlns="">
                <fieldName>AddressLine_1</fieldName>
                <fieldType>STRING</fieldType>
                <fieldLength>255</fieldLength>
            </fieldDefinitions>
            <fieldDefinitions xmlns="">
                <fieldName>AddressLine_2</fieldName>
                <fieldType>STRING</fieldType>
                <fieldLength>255</fieldLength>
            </fieldDefinitions>
            <fieldDefinitions xmlns="">
                <fieldName>City_in</fieldName>
                <fieldType>STRING</fieldType>
                <fieldLength>255</fieldLength>
            </fieldDefinitions>
            <fieldDefinitions xmlns="">
                <fieldName>State_in</fieldName>
                <fieldType>STRING</fieldType>
                <fieldLength>255</fieldLength>
            </fieldDefinitions>
            <fieldDefinitions xmlns="">
                <fieldName>Zip</fieldName>
                <fieldType>STRING</fieldType>
                <fieldLength>255</fieldLength>
            </fieldDefinitions>
            <fieldDefinitions xmlns="">
                <fieldName>Country</fieldName>
                <fieldType>STRING</fieldType>
                <fieldLength>255</fieldLength>
            </fieldDefinitions>
            <dataRows xmlns="">
                <value>3485 W. Harmon Ave.</value>
                <value/>
                <value>Las Vegas</value>
                <value>NV</value>
                <value>89103</value>
                <value>United States</value>
                <reserved>0</reserved>
            </dataRows>
        </SendArchitectServiceRequest>
    </s:Body>
</s:Envelope>


Your proposed method seems like the easiest approach. One other approach would be to use SOAP extensions to modifiy the SOAP response, removing the empty xmlns attribute. You would modify the SoapClientMessage in the BeforeDeserialize stage of the SoapMessageStage.


Since I have not heard any comments or answers to my second question, I will accept the answer I came across which was altering the auto-generated Reference.cs class XML element declarations from System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified) to System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Qualified).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜