简体   繁体   English

如何在Web服务客户端请求中配置SOAP XML名称空间?

[英]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 . 您将在SoapMessageStageBeforeDeserialize阶段中修改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.

相关问题 如何获取WCF Web服务请求的XML SOAP请求? - How do I get the XML SOAP request of an WCF Web service request? 客户端将SOAP请求发送到Web服务 - Client to send SOAP request to web service 如何配置C#Web服务客户端以并行发送HTTP请求标头和正文? - How do I configure a C# web service client to send HTTP request header and body in parallel? 在SOAP Web服务中获取请求和响应XML - Get Request and Response XML in SOAP web service 如何定义要包含在XML请求的标头中的XML名称空间,该XML标头将通过调用Web Service来发送? - How to define XML namespaces to be incuded in the header of XML request which will be send via invoke of a Web Service call? 如何使用SOAP with Attachments在ASMX Web服务中创建和返回CSV而不是XML? - How can I create and return CSV, not XML, in an ASMX Web Service, using SOAP with Attachments? 如何从动态soap-web-service捕获反序列化错误或xml? - how can I catch the deserialization error or xml from a dynamic soap-web-service? 我如何从Web服务获取肥皂请求和响应 - how do i obtain soap request and response from web service 我如何获得完整的肥皂请求(标题和xml正文) - How can i get full soap request (header and xml body) 如何在WCF Web服务上捕获肥皂消息? - How can I catch soap messages on WCF Web Service?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM