【问题标题】:gSOAP to WCF . Application/soap+xml; charset=utf-8gSOAP 到 WCF 。应用程序/肥皂+xml;字符集=utf-8
【发布时间】:2015-07-28 15:14:40
【问题描述】:

我在http://calculator.gear.host/Service1.svc 上运行了简单的网络服务

WCF Test Client 调用时没有问题,从 gSOAP c++ 客户端调用时出现错误。

HTTP/1.1 415 Cannot process the message because the content type 'application/soap+xml; charset=utf-8; action="http://tempuri.org/IService1/GetData"' was not the expected type 'text/xml; charset=utf-8'.

Fiddler 上的数据包:

WCF 测试客户端

请求

 POST http://calculator.gear.host/Service1.svc HTTP/1.1
    Content-Type: text/xml; charset=utf-8
    SOAPAction: "http://tempuri.org/ICalculator/GetData"
    Host: calculator.gear.host
    Content-Length: 158
    Expect: 100-continue
    Accept-Encoding: gzip, deflate
    Connection: Keep-Alive

    <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><GetData xmlns="http://tempuri.org/"><value>77</value></GetData></s:Body></s:Envelope>

gSOAP

请求

POST http://calculator.gear.host/Service1.svc HTTP/1.1
Host: calculator.gear.host
User-Agent: gSOAP/2.8
Content-Type: application/soap+xml; charset=utf-8; action="http://tempuri.org/IService1/GetData"
Content-Length: 536
Connection: close
SOAPAction: "http://tempuri.org/IService1/GetData"

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns4="http://schemas.datacontract.org/2004/07/WcfService2" xmlns:ns3="http://schemas.microsoft.com/2003/10/Serialization/" xmlns:ns1="http://tempuri.org/"><SOAP-ENV:Body><ns1:GetData><ns1:value>55</ns1:value></ns1:GetData></SOAP-ENV:Body></SOAP-ENV:Envelope>

回答

HTTP/1.1 415 Cannot process the message because the content type 'application/soap+xml; charset=utf-8; action="http://tempuri.org/IService1/GetData"' was not the expected type 'text/xml; charset=utf-8'.
Cache-Control: private
Content-Length: 0
Server: Microsoft-IIS/8.5
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Set-Cookie: ARRAffinity=7ac8ab2e2023ddbeb7d4f86322b3ed25bc003394df0030ed244a6fc5c10ec47c;Path=/;Domain=calculator.gear.host
Set-Cookie: WAWebSiteSID=9095f7410a074a959c2084564368b742; Path=/; HttpOnly
Date: Tue, 28 Jul 2015 15:03:28 GMT
Connection: close

【问题讨论】:

    标签: c++ wcf gsoap


    【解决方案1】:

    我对不是用 gSOAP 生成的服务有同样的问题(可能使用 C# 中的某些工具)。 对于您的客户端 gSOAP,使用选项 -1(生成 SOAP 1.1 绑定)重新编译您的 WSDL 文件 (soapcpp2.exe)。 这对我有用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-14
      • 2018-04-12
      • 1970-01-01
      • 2012-12-12
      • 1970-01-01
      • 2017-11-09
      相关资源
      最近更新 更多