1

我正在尝试在本地使用 Web 服务。我的服务器是用 C# 和客户端 c++ 和 gsoap 编写的。当我尝试编译我的 C++ 代码时,出现以下错误:

clientt.cpp
c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\xlocale(323) : 
warning C4530: C++ exception handler used, but unwind semantics are not
enabled. Specify /EHsc
clientt.cpp(8) : error C2661: 'WebService1SoapProxy::HelloWorld' : no
overloaded function takes 1 arguments

我认为,该函数必须采用 1 个参数。那有什么问题?

我使用的命令:

wsdl2h.exe -s -o calc.h calc.wsdl 
soapcpp2.exe -i calc.h 
cl client.cpp

.NET Web 服务服务器代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;

namespace webServiceDnm
{
/// <summary>
/// Summary description for WebService1
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
// [System.Web.Script.Services.ScriptService]
public class WebService1 : System.Web.Services.WebService
{

    [WebMethod]
    public string HelloWorld()
    {
        return "Hello World";
    }
}
}

C++ WEB服务客户端代码:

/* CalcClient.cpp */ 
#include "soapWebService1SoapProxy.h" 
#include "WebService1Soap.nsmap" 
void main() 
{ 
    WebService1SoapProxy service; 
    char* result; 
    if (service.HelloWorld(result) == SOAP_OK) 
        std::cout<< result << std::endl; 
    else 
        service.soap_stream_fault(std::cerr); 
}
4

0 回答 0