服务器生成的样本SOAP请求与客户端SOAP消息

时间:2017-05-23 16:47:14

标签: c# .net xml web-services soap

我正在开发一个应用程序,它需要来自客户端的示例SOAP请求消息,该消息由.svc文件生成并具有以下xml结构:

<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
 <soap12:Body>
   <GetInfo xmlns="http://sampleuri.org/">
     <GetInfoRequest>string</GetInfoRequest>
   </GetInfo>
 </soap12:Body>
</soap12:Envelope

相应客户端的SOAP请求具有以下xml结构:

<?xml version="1.0" encoding="utf-16"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Header>
        <To s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://localhost:10000/WcfSmsStringService.svc</To>
        <Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://www.sampleuri/soap/GetInfo</Action>
    </s:Header>
    <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <GetInfoRequest xmlns="http://www.sampleuri/soap">
            &lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-16&quot;?&gt;
            &lt;GetInfoRequest xmlns=&quot;http://www.sampleuri/XMLSchema" /&gt;
        </GetInfoRequest>
    </s:Body>
</s:Envelope>

客户端收到以下错误:

发生例外情况 响应消息的内容类型text / html与绑定的内容类型(text / xml; charset = utf-8)不匹配。如果使用自定义编码器,请确保正确实现IsContentTypeSupported方法。响应的前75个字节是:'由于发生内部服务器错误,无法显示页面。'。

你能给我一个预约,这是解决这个问题的最佳方法吗?

有没有办法更改从服务器自动生成和预期的示例SOAP请求消息,还是有另一种更好的方法?

经过长时间的研究,我仍然没有找到解决这个问题的方法。

提前致谢!

1 个答案:

答案 0 :(得分:0)

您正在发送一个SOAp 1.1信封,而服务器期待SOAP 1.2。请注意消息之间SOAP名称空间的区别。 编辑:至少,如果响应的前几个字节不会说“内部服务器错误”,那就是我要说的。我会在您的服务器实现上查找问题的原因。如果客户端邮件无效,您可能会收到一些错误的请求&#39;响应。

相关问题