第 1 步,我使用 ASP.NET (C#) 创建了一个 WebService:
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class WebService1 : System.Web.Services.WebService
{
[WebMethod]
public string HelloWorld(int a, int b)
{
return a.ToString() + "," + b.ToString();
}
}
第2步,然后我使用gsoap_2.8.12生成代码,以下命令:
wsdl2h -c -o a.h http://localhost:29556/WebService1.asmx?WSDL
soapcpp2 -c -C -I import a.h
step3、在VC中创建一个空的C项目,添加如下文件:soapH.h soapStub.h stdsoap2.h soapC.c soapClient.c stdsoap2.c
step4,配置文件夹,并创建一个新类:
#include <stdio.h>
#include "WebService1Soap.nsmap";
void main()
{
struct soap soap;
int ret;
struct _ns1__HelloWorld hello;
struct _ns1__HelloWorldResponse respHello;
int arg1, arg2;
soap_init(&soap);
hello.a = 2;
hello.b = 3;
ret = soap_call___ns1__HelloWorld(&soap, NULL, NULL, &hello, &respHello);
if (ret == SOAP_OK)
{
printf("return :%s", respHello.HelloWorldResult);
}
else
{
printf("error :%d", ret);
}
getchar();
}
问题:返回值是“0,0”,我们期望它应该是“2,3”,请告诉我这些东西我错过了什么?谢谢!