[英]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. 我没有收到SOAP错误,但是没有得到有效的结果集。 A colleague of mine has written a client in RPG on the OS400 and it returns a valid resultset. 我的一位同事在OS400上用RPG编写了一个客户端,它返回有效的结果集。 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. 在Fiddler2中比较两个请求的RAW请求时,我注意到的唯一明显区别是我的c#客户端具有xmlns =“”的 SOAP xml元素,而他没有。 Is it possible to remove said empty namespace declarations? 是否可以删除空的命名空间声明? Please see the referenced SOAP request below: 请参阅下面引用的SOAP请求:
<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. 另一种方法是使用SOAP扩展来修改SOAP响应,删除空的xmlns属性。 You would modify the SoapClientMessage in the BeforeDeserialize
stage of the SoapMessageStage . 您将在SoapMessageStage的BeforeDeserialize
阶段中修改SoapClientMessage 。
由于我没有听到对第二个问题的任何评论或答案,因此我将接受我遇到的答案,该答案是更改System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)
的自动生成的Reference.cs类XML元素声明System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)
到System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Qualified)
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.