我正在编写一个简单的cmd客户端,以尝试使用我开发的WCF Web服务,以便测试如何使用非托管C++连接到Web服务。

我一直在逐步按照本教程http://www.blinnov.com/en/2008/01/22/wcf-service-unmanaged-client/进行操作,但仍然无法成功使用该服务。

#include "BasicHttpBinding_USCOREIService1.nsmap"
#include "soapBasicHttpBinding_USCOREIService1Proxy.h"
#include <iostream>
#include <string>

using namespace std;


int main(int argc, char **argv)
{
BasicHttpBinding_USCOREIService1Proxy myProxy;
static const char* const endPoint = "http://localhost:50181/Service1.svc";

myProxy.soap_endpoint = endPoint;
_ns1__GetData param;
_ns1__GetDataResponse response;
param.fileName = &std::string("house.ifc");

if ( myProxy.GetData(&param, &response) == SOAP_OK) {
    cout << "Hello" << endl; //Succeeded
}
else {

    myProxy.soap_stream_fault(std::cerr);
}
return 0;
}

它总是给我
错误415错误:SOAP-ENV:Server [无子代码]
“HTTP错误”
详细信息:HTTP / 1.1 415不支持的媒体类型
我全天都在努力完成它,但是仍然没有什么新鲜的东西。 :(

最佳答案

这是因为gSOAP客户端和WCF服务不能与SOAP 1.2很好地配合使用。
如果将soapcpp2与“-1”开关一起使用来强制执行SOAP 1.1,则它将起作用。

我已经在Ubuntu上使用gSOAP 2.8.4对其进行了测试,并且可以正常工作。

关于c++ - 使用gSOAP连接到WCF Web服务,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/4530707/

10-14 13:10
查看更多