先给出wsdl2h和soapcpp2的生成客户端代码

wsdl2h -s  -o calc.h http://www.genivia.com/calc.wsdl
soapcpp2 -i -C -x -Iimport calc.h

  生成的文件如下图,我用test.bat封装了上面的指令:

  gSoap客户端示例程序

  客户端代码

#include "stdafx.h"
#include "soapcalcProxy.h"
#include "calc.nsmap"

int _tmain(int argc, _TCHAR* argv[])
{
    calcProxy service;
    double result;
    if (service.add(1.0,2.0,result) == SOAP_OK)
    {
        std::cout << "The sum of 1.0 and 2.0 is " << result << std::endl;
    }
    else
    {
        service.soap_stream_fault(std::cerr);
    }
    service.destroy();
    ::Sleep(6000);
    return 0;
}

  运行后,soap代理类使用默认web service接口地址进行add运算。默认地址写在add函数内,可跟踪add查看。

相关文章:

  • 2022-12-23
  • 2021-06-12
  • 2022-12-23
  • 2022-02-12
  • 2021-05-17
  • 2021-12-06
  • 2021-09-14
  • 2022-12-23
猜你喜欢
  • 2021-12-07
  • 2021-07-10
  • 2021-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-28
相关资源
相似解决方案