我试图使用SOAP 1.2协议编写一个简单的WCF服务器+ gSOAP的客户机验证的概念应用。这里的服务器代码:

[ServiceContract(Namespace="http://test.com")]
public interface IService1
{
    [OperationContract]
    void HelloWorld();
}

[ServiceBehavior(Namespace = "http://test.com")]
public class Service1 : IService1
{
    public void HelloWorld()
    {
    }
}

static void Main(string[] args)
{
    var svc =  new Service1();
    Uri uri = new Uri("http://localhost:8201/Service1");
    ServiceHost host = new ServiceHost(typeof(Service1), uri);
    host.Description.Namespace = "http://test.com";

    var binding = new WSHttpBinding() { Namespace = "http://test.com" };
    ServiceEndpoint endpoint = host.AddServiceEndpoint(typeof(IService1), binding, uri);
    endpoint.Behaviors.Add(new InlineXsdInWsdlBehavior());

    host.Description.Behaviors.Add(new ServiceMetadataBehavior() { HttpGetEnabled = true });
    var mex = host.AddServiceEndpoint(typeof(IMetadataExchange), MetadataExchangeBindings.CreateMexHttpBinding(), "mex");
    host.Open();

    Console.ReadLine();
}

然后我启动服务,并使用下面的命令生成代码:

wsdl2h.exe -gyf -t WS/WS-typemap.dat -o Service.h http://localhost:8201/Service1?wsdl WS/WS-Addressing05.xsd
soapcpp2.exe -C -L -w -x -i -2 Service.h -ID:\...\gsoap-2.7\gsoap\import

然后我编译以下C ++代码:

#include "soapWSHttpBinding_USCOREIService1Proxy.h"
#include "WSHttpBinding_USCOREIService1.nsmap"
#include "stdsoap2.h" 

int _tmain(int argc, _TCHAR* argv[])
{
    WSHttpBinding_USCOREIService1Proxy svc;

    _ns1__HelloWorld req;
    _ns1__HelloWorldResponse rsp;
    int hr = svc.HelloWorld( &req, &rsp );
    if ( hr != SOAP_OK )
    {
        _tprintf( _T("Error: %i\n"), hr );
    }

    return 0;
}

和该生成错误8(SOAP_MUSTUNDERSTAND)。有没有人产生工作WCF到gSOAP的链接呢?我在做什么错了?

有帮助吗?

解决方案

我想在soapcpp2 -a开关具有固定的错误8,所以开关现在是:

soapcpp2.exe -C -L -w -x -i -2 -a Service.h -I<...path...>
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top