我正在开发一个应用程序,该应用程序需要来自客户端的示例 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">
<?xml version="1.0" encoding="utf-16"?>
<GetInfoRequest xmlns="http://www.sampleuri/XMLSchema" />
</GetInfoRequest>
</s:Body>
</s:Envelope>
客户端收到以下错误:
发生异常 响应消息的内容类型 text/html 与绑定的内容类型不匹配(text/xml;charset=utf-8)。如果使用自定义编码器,请确保正确实现 IsContentTypeSupport 方法。响应的前 75 个字节是:"由于发生内部服务器错误,无法显示页面。
你能给我一个约会,这是解决这个问题的最佳方法吗?
有没有办法更改自动生成并期望从服务器获得的示例 SOAP 请求消息,或者有另一种更好的方法?
经过长时间的研究,我仍然没有找到解决这个问题的方法。
提前感谢!
您正在发送 SOAp 1.1 信封,而服务器需要 SOAP 1.2。请注意消息之间 SOAP 命名空间的差异。 编辑:至少,如果响应的前几个字节不会说"内部服务器错误",我会这么说。我会在您的服务器实现上寻找问题的原因。如果客户端消息无效,您可能会收到一些"错误请求"响应。