C-gsoap客户端

gsoap 使用说明

生成的代码为纯C的代码
详情请查阅dev.html#client-c

1、进入目录

D:\path-conf-items\gsoap_2.8.127\gsoap-2.8\gsoap\bin\win32

2、具体步骤

1、使用以下命令前需要将 soap12.h 与 typemap.dat文件放入该目录下。

wsdl2h.exe -c -o  calc.h http://www.genivia.com/calc.wsdl
soapcpp2 -CL calc.h

2、将需要的文件放入新建的工程中

  • calc.nsmap
  • soapH.h
  • soapC.c
  • soapClient.c
  • soapStub.h
  • soap12.h

以下文件在 D:\path-conf-items\gsoap_2.8.127\gsoap-2.8\gsoap 目录下

  • stdsoap2.h
  • stdsoap2.c

3、简单测试

注意:以下示例我没有进行过测试,主要是我得到了我想要的结果,这里的例子只是官网上的例子,只具有参考意义

#include "calc.nsmap" // XML namespace mapping table (only needed once at the global level)
#include "soapH.h"    // client stubs, serializers, etc.

int main()
{
  struct soap *soap = soap_new(); // allocate and initialize a context
  double sum;
  if (soap_call_ns2__add(soap, NULL, NULL, 1.23, 4.56, &sum) == SOAP_OK)
    printf("Sum = %g\n", sum);
  else
    soap_print_fault(soap, stderr);
  soap_destroy(soap); // delete managed deserialized C++ instances
  soap_end(soap);     // delete other managed data
  soap_free(soap);    // free the soap struct context data
}
posted on 2023-06-06 15:02  woshku  阅读(20)  评论(0编辑  收藏  举报