gSoap客户端示例程序

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

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

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

  

  客户端代码

#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查看。

原文地址:https://www.cnblogs.com/hgwang/p/5848975.html