我们可以通过gsoap将wsdl方式的WebServer服务生成对应的C/C++接口,供C/C++调用。 gsoap的下载地址为:https://sourceforge.net/projects/gsoap2/当前的最新版本为:2.8.43。 将gsoap解压,进入到bin/win32目录
我们可以通过gsoap将wsdl方式的WebServer服务生成对应的C/C++接口,供C/C++调用。 gsoap的下载地址为:https://sourceforge.net/projects/gsoap2/当前的最新版本为:2.8.43。 将gsoap解压,进入到bin/win32目录下,下面有wsdl2h.exe和soapcpp2.exe两个文件。 运行(C++ Client):
PS C:\Users\soft\Downloads\gsoap-2.8\gsoap\bin\win32> .\wsdl2h -o calc.h http://www.genivia.com/calc.wsdl
Saving calc.h
** The gSOAP WSDL/WADL/XSD processor for C and C++, wsdl2h release 2.8.43
** Copyright (C) 2000-2017 Robert van Engelen, Genivia Inc.
** All Rights Reserved. This product is provided "as is", without any warranty.
** The wsdl2h tool and its generated software are released under the GPL.
** ----------------------------------------------------------------------------
** A commercial use license is available from Genivia Inc., contact@genivia.com
** ----------------------------------------------------------------------------
Cannot open file "typemap.dat"
Problem reading type map file 'typemap.dat'.
Using internal type definitions for C++ instead.
Connecting to 'http://www.genivia.com/calc.wsdl' to retrieve WSDL/WADL or XSD... connected, receiving...
Done reading 'http://www.genivia.com/calc.wsdl'
To finalize code generation, execute:
> soapcpp2 calc.h
Or to generate C++ proxy and service classes:
> soapcpp2 -j calc.h
执行完毕后会在当前目录下面生成一个calc.h的文件。内容如下:
/* calc.h
Generated by wsdl2h 2.8.43 from http://www.genivia.com/calc.wsdl and typemap.dat
2017-02-10 07:34:11 GMT
DO NOT INCLUDE THIS FILE DIRECTLY INTO YOUR PROJECT BUILDS
USE THE soapcpp2-GENERATED SOURCE CODE FILES FOR YOUR PROJECT BUILDS
gSOAP XML Web services tools
Copyright (C) 2000-2016, Robert van Engelen, Genivia Inc. All Rights Reserved.
This program is released under the GPL with the additional exemption that
compiling, linking, and/or using OpenSSL is allowed. --------------------------------------------------------------------------------
A commercial use license is available from Genivia Inc., contact@genivia.com --------------------------------------------------------------------------------
*/
/** @page page_notes Notes
@note HINTS:
- Run soapcpp2 on calc.h to generate the SOAP/XML processing logic.
Use soapcpp2 -I to specify paths for #import
To build with STL, 'stl.h' is imported from 'import' dir in package.
Use soapcpp2 -j to generate improved proxy and server classes.
Use soapcpp2 -r to generate a report.
- Use wsdl2h -c and -s to generate pure C code or C++ code without STL.
- Use 'typemap.dat' to control namespace bindings and type mappings.
It is strongly recommended to customize the names of the namespace prefixes
generated by wsdl2h. To do so, modify the prefix bindings in the Namespaces
section below and add the modified lines to 'typemap.dat' to rerun wsdl2h.
- Run Doxygen (www.doxygen.org) on this file to generate documentation.
- Use wsdl2h -R to generate REST operations.
- Use wsdl2h -nname to use name as the base namespace prefix instead of 'ns'.
- Use wsdl2h -Nname for service prefix and produce multiple service bindings
- Use wsdl2h -d to enable DOM support for xsd:anyType.
- Use wsdl2h -g to auto-generate readers and writers for root elements.
- Use wsdl2h -b to auto-generate bi-directional operations (duplex ops).
- Use wsdl2h -U to map XML names to C++ Unicode identifiers instead of _xNNNN.
- Use wsdl2h -u to disable the generation of unions.
- Struct/class members serialized as XML attributes are annotated with a '@'.
- Struct/class members that have a special role are annotated with a '$'.
@warning
DO NOT INCLUDE THIS ANNOTATED FILE DIRECTLY IN YOUR PROJECT SOURCE CODE.
USE THE FILES GENERATED BY soapcpp2 FOR YOUR PROJECT'S SOURCE CODE:
THE soapStub.h FILE CONTAINS THIS CONTENT WITHOUT ANNOTATIONS.
@copyright LICENSE:
@verbatim --------------------------------------------------------------------------------
gSOAP XML Web services tools
Copyright (C) 2000-2017, Robert van Engelen, Genivia Inc. All Rights Reserved.
The wsdl2h tool and its generated software are released under the GPL.
This software is released under the GPL with the additional exemption that
compiling, linking, and/or using OpenSSL is allowed. --------------------------------------------------------------------------------
GPL license.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place, Suite 330, Boston, MA 02111-1307 USA
Author contact information:
engelen@genivia.com / engelen@acm.org
This program is released under the GPL with the additional exemption that
compiling, linking, and/or using OpenSSL is allowed. --------------------------------------------------------------------------------
A commercial-use license is available from Genivia, Inc., contact@genivia.com --------------------------------------------------------------------------------
@endverbatim
*/
//gsoapopt c++,w
/******************************************************************************\
* *
* Definitions *
* http://websrv.cs.fsu.edu/~engelen/calc.wsdl *
* *
\******************************************************************************/
/******************************************************************************\
* *
* $CONTAINER *
* std::vector *
* *
\******************************************************************************/
template <class T> class std::vector;
/******************************************************************************\
* *
* Import *
* *
\******************************************************************************/
#import "stl.h" // enable STL containers when used (option -s removes STL dependency)
/******************************************************************************\
* *
* Schema Namespaces *
* *
\******************************************************************************/
/* NOTE:
It is strongly recommended to customize the names of the namespace prefixes
generated by wsdl2h. To do so, modify the prefix bindings below and add the
modified lines to typemap.dat to rerun wsdl2h:
ns1 = "http://websrv.cs.fsu.edu/~engelen/calc.wsdl"
ns2 = "urn:calc"
*/
#define SOAP_NAMESPACE_OF_ns2 "urn:calc"
//gsoap ns2 schema namespace: urn:calc
//gsoap ns2 schema form: unqualified
/******************************************************************************\
* *
* Built-in Schema Types and Top-Level Elements and Attributes *
* *
\******************************************************************************/
/******************************************************************************\
* *
* Forward Declarations *
* *
\******************************************************************************/
/******************************************************************************\
* *
* Schema Types and Top-Level Elements and Attributes *
* urn:calc *
* *
\******************************************************************************/
/******************************************************************************\
* *
* Schema Complex Types and Top-Level Elements *
* urn:calc *
* *
\******************************************************************************/
/******************************************************************************\
* *
* Additional Top-Level Elements *
* urn:calc *
* *
\******************************************************************************/
/******************************************************************************\
* *
* Additional Top-Level Attributes *
* urn:calc *
* *
\******************************************************************************/
/******************************************************************************\
* *
* Services *
* *
\******************************************************************************/
//gsoap ns2 service name: calc
//gsoap ns2 service type: calcPortType
//gsoap ns2 service port: http://websrv.cs.fsu.edu/~engelen/calcserver.cgi
//gsoap ns2 service namespace: urn:calc
//gsoap ns2 service transport: http://schemas.xmlsoap.org/soap/http
/** @mainpage calc Definitions
@section calc_bindings Service Bindings
- @ref calc
@section calc_more More Information
- @ref page_notes "Notes"
- @ref page_XMLDataBinding "XML Data Binding"
- @ref SOAP_ENV__Header "SOAP Header Content" (when applicable)
- @ref SOAP_ENV__Detail "SOAP Fault Detail Content" (when applicable)
*/
/**
@page calc Binding "calc"
@section calc_service Service Documentation "calc"
gSOAP 2.7.9k generated service definition
@section calc_operations Operations of Binding "calc"
- @ref ns2__add
- @ref ns2__sub
- @ref ns2__mul
- @ref ns2__div
- @ref ns2__pow
@section calc_ports Default endpoints of Binding "calc"
- http://websrv.cs.fsu.edu/~engelen/calcserver.cgi
@note Use wsdl2h option -Nname to change the service binding prefix name
*/
/******************************************************************************\
* *
* Service Binding *
* calc *
* *
\******************************************************************************/
/******************************************************************************\
* *
* Service Operation *
* ns2__add *
* *
\******************************************************************************/
/** Operation "ns2__add" of service binding "calc".
Service definition of function ns__add
- SOAP RPC encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
- Default endpoints:
- http://websrv.cs.fsu.edu/~engelen/calcserver.cgi
- Addressing input action: ""
- Addressing output action: "Response"
C stub function (defined in soapClient.c[pp] generated by soapcpp2):
@code
int soap_call_ns2__add(
struct soap *soap,
NULL, // char *endpoint = NULL selects default endpoint for this operation
NULL, // char *action = NULL selects default action for this operation
// input parameters:
double a,
double b,
// output parameters:
double &result
);
@endcode
C server function (called from the service dispatcher defined in soapServer.c[pp]):
@code
int ns2__add(
struct soap *soap,
// input parameters:
double a,
double b,
// output parameters:
double &result
);
@endcode
C++ proxy class (defined in soapcalcProxy.h generated with soapcpp2):
@code
class calcProxy;
@endcode
Important: use soapcpp2 option '-j' (or '-i') to generate improved and easy-to-use proxy classes;
C++ service class (defined in soapcalcService.h generated with soapcpp2):
@code
class calcService;
@endcode
Important: use soapcpp2 option '-j' (or '-i') to generate improved and easy-to-use service classes;
*/
//gsoap ns2 service method-protocol: add SOAP
//gsoap ns2 service method-style: add rpc
//gsoap ns2 service method-encoding: add http://schemas.xmlsoap.org/soap/encoding/
//gsoap ns2 service method-action: add ""
//gsoap ns2 service method-output-action: add Response
int ns2__add(
double :a, ///< Input parameter, : unqualified name as per RPC encoding
double :b, ///< Input parameter, : unqualified name as per RPC encoding
double &:result ///< Output parameter, : unqualified name as per RPC encoding
);
/******************************************************************************\
* *
* Service Operation *
* ns2__sub *
* *
\******************************************************************************/
/** Operation "ns2__sub" of service binding "calc".
Service definition of function ns__sub
- SOAP RPC encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
- Default endpoints:
- http://websrv.cs.fsu.edu/~engelen/calcserver.cgi
- Addressing input action: ""
- Addressing output action: "Response"
C stub function (defined in soapClient.c[pp] generated by soapcpp2):
@code
int soap_call_ns2__sub(
struct soap *soap,
NULL, // char *endpoint = NULL selects default endpoint for this operation
NULL, // char *action = NULL selects default action for this operation
// input parameters:
double a,
double b,
// output parameters:
double &result
);
@endcode
C server function (called from the service dispatcher defined in soapServer.c[pp]):
@code
int ns2__sub(
struct soap *soap,
// input parameters:
double a,
double b,
// output parameters:
double &result
);
@endcode
C++ proxy class (defined in soapcalcProxy.h generated with soapcpp2):
@code
class calcProxy;
@endcode
Important: use soapcpp2 option '-j' (or '-i') to generate improved and easy-to-use proxy classes;
C++ service class (defined in soapcalcService.h generated with soapcpp2):
@code
class calcService;
@endcode
Important: use soapcpp2 option '-j' (or '-i') to generate improved and easy-to-use service classes;
*/
//gsoap ns2 service method-protocol: sub SOAP
//gsoap ns2 service method-style: sub rpc
//gsoap ns2 service method-encoding: sub http://schemas.xmlsoap.org/soap/encoding/
//gsoap ns2 service method-action: sub ""
//gsoap ns2 service method-output-action: sub Response
int ns2__sub(
double :a, ///< Input parameter, : unqualified name as per RPC encoding
double :b, ///< Input parameter, : unqualified name as per RPC encoding
double &:result ///< Output parameter, : unqualified name as per RPC encoding
);
/******************************************************************************\
* *
* Service Operation *
* ns2__mul *
* *
\******************************************************************************/
/** Operation "ns2__mul" of service binding "calc".
Service definition of function ns__mul
- SOAP RPC encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
- Default endpoints:
- http://websrv.cs.fsu.edu/~engelen/calcserver.cgi
- Addressing input action: ""
- Addressing output action: "Response"
C stub function (defined in soapClient.c[pp] generated by soapcpp2):
@code
int soap_call_ns2__mul(
struct soap *soap,
NULL, // char *endpoint = NULL selects default endpoint for this operation
NULL, // char *action = NULL selects default action for this operation
// input parameters:
double a,
double b,
// output parameters:
double &result
);
@endcode
C server function (called from the service dispatcher defined in soapServer.c[pp]):
@code
int ns2__mul(
struct soap *soap,
// input parameters:
double a,
double b,
// output parameters:
double &result
);
@endcode
C++ proxy class (defined in soapcalcProxy.h generated with soapcpp2):
@code
class calcProxy;
@endcode
Important: use soapcpp2 option '-j' (or '-i') to generate improved and easy-to-use proxy classes;
C++ service class (defined in soapcalcService.h generated with soapcpp2):
@code
class calcService;
@endcode
Important: use soapcpp2 option '-j' (or '-i') to generate improved and easy-to-use service classes;
*/
//gsoap ns2 service method-protocol: mul SOAP
//gsoap ns2 service method-style: mul rpc
//gsoap ns2 service method-encoding: mul http://schemas.xmlsoap.org/soap/encoding/
//gsoap ns2 service method-action: mul ""
//gsoap ns2 service method-output-action: mul Response
int ns2__mul(
double :a, ///< Input parameter, : unqualified name as per RPC encoding
double :b, ///< Input parameter, : unqualified name as per RPC encoding
double &:result ///< Output parameter, : unqualified name as per RPC encoding
);
/******************************************************************************\
* *
* Service Operation *
* ns2__div *
* *
\******************************************************************************/
/** Operation "ns2__div" of service binding "calc".
Service definition of function ns__div
- SOAP RPC encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
- Default endpoints:
- http://websrv.cs.fsu.edu/~engelen/calcserver.cgi
- Addressing input action: ""
- Addressing output action: "Response"
C stub function (defined in soapClient.c[pp] generated by soapcpp2):
@code
int soap_call_ns2__div(
struct soap *soap,
NULL, // char *endpoint = NULL selects default endpoint for this operation
NULL, // char *action = NULL selects default action for this operation
// input parameters:
double a,
double b,
// output parameters:
double &result
);
@endcode
C server function (called from the service dispatcher defined in soapServer.c[pp]):
@code
int ns2__div(
struct soap *soap,
// input parameters:
double a,
double b,
// output parameters:
double &result
);
@endcode
C++ proxy class (defined in soapcalcProxy.h generated with soapcpp2):
@code
class calcProxy;
@endcode
Important: use soapcpp2 option '-j' (or '-i') to generate improved and easy-to-use proxy classes;
C++ service class (defined in soapcalcService.h generated with soapcpp2):
@code
class calcService;
@endcode
Important: use soapcpp2 option '-j' (or '-i') to generate improved and easy-to-use service classes;
*/
//gsoap ns2 service method-protocol: div SOAP
//gsoap ns2 service method-style: div rpc
//gsoap ns2 service method-encoding: div http://schemas.xmlsoap.org/soap/encoding/
//gsoap ns2 service method-action: div ""
//gsoap ns2 service method-output-action: div Response
int ns2__div(
double :a, ///< Input parameter, : unqualified name as per RPC encoding
double :b, ///< Input parameter, : unqualified name as per RPC encoding
double &:result ///< Output parameter, : unqualified name as per RPC encoding
);
/******************************************************************************\
* *
* Service Operation *
* ns2__pow *
* *
\******************************************************************************/
/** Operation "ns2__pow" of service binding "calc".
Service definition of function ns__pow
- SOAP RPC encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
- Default endpoints:
- http://websrv.cs.fsu.edu/~engelen/calcserver.cgi
- Addressing input action: ""
- Addressing output action: "Response"
C stub function (defined in soapClient.c[pp] generated by soapcpp2):
@code
int soap_call_ns2__pow(
struct soap *soap,
NULL, // char *endpoint = NULL selects default endpoint for this operation
NULL, // char *action = NULL selects default action for this operation
// input parameters:
double a,
double b,
// output parameters:
double &result
);
@endcode
C server function (called from the service dispatcher defined in soapServer.c[pp]):
@code
int ns2__pow(
struct soap *soap,
// input parameters:
double a,
double b,
// output parameters:
double &result
);
@endcode
C++ proxy class (defined in soapcalcProxy.h generated with soapcpp2):
@code
class calcProxy;
@endcode
Important: use soapcpp2 option '-j' (or '-i') to generate improved and easy-to-use proxy classes;
C++ service class (defined in soapcalcService.h generated with soapcpp2):
@code
class calcService;
@endcode
Important: use soapcpp2 option '-j' (or '-i') to generate improved and easy-to-use service classes;
*/
//gsoap ns2 service method-protocol: pow SOAP
//gsoap ns2 service method-style: pow rpc
//gsoap ns2 service method-encoding: pow http://schemas.xmlsoap.org/soap/encoding/
//gsoap ns2 service method-action: pow ""
//gsoap ns2 service method-output-action: pow Response
int ns2__pow(
double :a, ///< Input parameter, : unqualified name as per RPC encoding
double :b, ///< Input parameter, : unqualified name as per RPC encoding
double &:result ///< Output parameter, : unqualified name as per RPC encoding
);
/**
@page calc Binding "calc"
@section calc_policy_enablers Policy Enablers of Binding "calc"
None specified.
*/
/******************************************************************************\
* *
* XML Data Binding *
* *
\******************************************************************************/
/**
@page page_XMLDataBinding XML Data Binding
SOAP/XML services use data bindings contractually bound by WSDL and auto-
generated by wsdl2h and soapcpp2 (see Service Bindings). Plain data bindings
are adopted from XML schemas as part of the WSDL types section or when running
wsdl2h on a set of schemas to produce non-SOAP-based XML data bindings.
The following readers and writers are C/C++ data type (de)serializers auto-
generated by wsdl2h and soapcpp2. Run soapcpp2 on this file to generate the
(de)serialization code, which is stored in soapC.c[pp]. Include "soapH.h" in
your code to import these data type and function declarations. Only use the
soapcpp2-generated files in your project build. Do not include the wsdl2h-
generated .h file in your code.
Data can be read and deserialized from:
- an int file descriptor, using soap->recvfd = fd
- a socket, using soap->socket = (int)...
- a C++ stream (istream, stringstream), using soap->is = (istream*)...
- a C string, using soap->is = (const char*)...
- any input, using the soap->frecv() callback
Data can be serialized and written to:
- an int file descriptor, using soap->sendfd = (int)...
- a socket, using soap->socket = (int)...
- a C++ stream (ostream, stringstream), using soap->os = (ostream*)...
- a C string, using soap->os = (const char**)...
- any output, using the soap->fsend() callback
The following options are available for (de)serialization control:
- soap->encodingStyle = NULL; to remove SOAP 1.1/1.2 encodingStyle
- soap_mode(soap, SOAP_XML_TREE); XML without id-ref (no cycles!)
- soap_mode(soap, SOAP_XML_GRAPH); XML with id-ref (including cycles)
- soap_set_namespaces(soap, struct Namespace *nsmap); to set xmlns bindings
@section ns2 Top-level root elements of schema "urn:calc"
*/
/* End of calc.h */
根据头文件生成cpp文件:
PS C:\Users\soft\Downloads\gsoap-2.8\gsoap\bin\win32> .\soapcpp2 -j -CL -I C:\Users\soft\Downloads\gsoap-2.8\gsoap\impor
t calc.h
** The gSOAP code generator for C and C++, soapcpp2 release 2.8.43
** Copyright (C) 2000-2017, Robert van Engelen, Genivia Inc.
** All Rights Reserved. This product is provided "as is", without any warranty.
** The soapcpp2 tool and its generated software are released under the GPL.
** ----------------------------------------------------------------------------
** A commercial use license is available from Genivia Inc., contact@genivia.com
** ----------------------------------------------------------------------------
Saving soapStub.h annotated copy of the source interface file
Saving soapH.h serialization functions to #include in projects
Using ns2 service name: calc
Using ns2 service style: document
Using ns2 service encoding: literal
Using ns2 service location: http://websrv.cs.fsu.edu/~engelen/calcserver.cgi
Using ns2 schema namespace: urn:calc
Saving soapcalcProxy.h client proxy class
Saving soapcalcProxy.cpp client proxy class
Saving calc.add.req.xml sample SOAP/XML request
Saving calc.add.res.xml sample SOAP/XML response
Saving calc.sub.req.xml sample SOAP/XML request
Saving calc.sub.res.xml sample SOAP/XML response
Saving calc.mul.req.xml sample SOAP/XML request
Saving calc.mul.res.xml sample SOAP/XML response
Saving calc.div.req.xml sample SOAP/XML request
Saving calc.div.res.xml sample SOAP/XML response
Saving calc.pow.req.xml sample SOAP/XML request
Saving calc.pow.res.xml sample SOAP/XML response
Saving calc.nsmap namespace mapping table
Saving soapC.cpp serialization functions
Compilation successful
当前目录下会生成一堆文件:
PS C:\Users\soft\Downloads\gsoap-2.8\gsoap\bin\win32> ls
目录: C:\Users\soft\Downloads\gsoap-2.8\gsoap\bin\win32
Mode LastWriteTime Length Name
---- ------------- ------ ---- -a---- 2017-2-10 16:21 498 calc.add.req.xml -a---- 2017-2-10 16:21 509 calc.add.res.xml -a---- 2017-2-10 16:21 498 calc.div.req.xml -a---- 2017-2-10 16:21 509 calc.div.res.xml -a---- 2017-2-10 15:34 27307 calc.h -a---- 2017-2-10 16:21 498 calc.mul.req.xml -a---- 2017-2-10 16:21 509 calc.mul.res.xml -a---- 2017-2-10 16:21 577 calc.nsmap -a---- 2017-2-10 16:21 498 calc.pow.req.xml -a---- 2017-2-10 16:21 509 calc.pow.res.xml -a---- 2017-2-10 16:21 498 calc.sub.req.xml -a---- 2017-2-10 16:21 509 calc.sub.res.xml -a---- 2017-2-10 16:21 97689 soapC.cpp -a---- 2017-2-10 16:21 14594 soapcalcProxy.cpp -a---- 2017-2-10 16:21 5276 soapcalcProxy.h -a---- 2017-2-5 11:47 655360 soapcpp2.exe -a---- 2017-2-10 16:21 66296 soapH.h -a---- 2017-2-10 16:21 21457 soapStub.h -a---- 2017-2-5 11:47 1269760 wsdl2h.exe
由于文件内容比较多就不一一列出来。 生成c接口,在wsdl2h 加上-c生成c的调用接口:
PS C:\Users\soft\Downloads\gsoap-2.8\gsoap\bin\win32> .\wsdl2h -c -o calc.h http://www.genivia.com/calc.wsdl
Saving calc.h
** The gSOAP WSDL/WADL/XSD processor for C and C++, wsdl2h release 2.8.43
** Copyright (C) 2000-2017 Robert van Engelen, Genivia Inc.
** All Rights Reserved. This product is provided "as is", without any warranty.
** The wsdl2h tool and its generated software are released under the GPL.
** ----------------------------------------------------------------------------
** A commercial use license is available from Genivia Inc., contact@genivia.com
** ----------------------------------------------------------------------------
Cannot open file "typemap.dat"
Problem reading type map file 'typemap.dat'.
Using internal type definitions for C instead.
Connecting to 'http://www.genivia.com/calc.wsdl' to retrieve WSDL/WADL or XSD... connected, receiving...
Done reading 'http://www.genivia.com/calc.wsdl'
To finalize code generation, execute:
> soapcpp2 calc.h
生成的C的头文件如下:
PS C:\Users\soft\Downloads\gsoap-2.8\gsoap\bin\win32> ls
目录: C:\Users\soft\Downloads\gsoap-2.8\gsoap\bin\win32
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 2017-2-10 16:26 24146 calc.h
-a---- 2017-2-5 11:47 655360 soapcpp2.exe
-a---- 2017-2-5 11:47 1269760 wsdl2h.exe
生成.c文件:
PS C:\Users\soft\Downloads\gsoap-2.8\gsoap\bin\win32> .\soapcpp2 -CL -I C:\Users\soft\Downloads\gsoap-2.8\gsoap\import calc.h
** The gSOAP code generator for C and C++, soapcpp2 release 2.8.43
** Copyright (C) 2000-2017, Robert van Engelen, Genivia Inc.
** All Rights Reserved. This product is provided "as is", without any warranty.
** The soapcpp2 tool and its generated software are released under the GPL.
** ----------------------------------------------------------------------------
** A commercial use license is available from Genivia Inc., contact@genivia.com
** ----------------------------------------------------------------------------
Saving soapStub.h annotated copy of the source interface file
Saving soapH.h serialization functions to #include in projects
Using ns2 service name: calc
Using ns2 service style: document
Using ns2 service encoding: literal
Using ns2 service location: http://websrv.cs.fsu.edu/~engelen/calcserver.cgi
Using ns2 schema namespace: urn:calc
Saving calc.add.req.xml sample SOAP/XML request
Saving calc.add.res.xml sample SOAP/XML response
Saving calc.sub.req.xml sample SOAP/XML request
Saving calc.sub.res.xml sample SOAP/XML response
Saving calc.mul.req.xml sample SOAP/XML request
Saving calc.mul.res.xml sample SOAP/XML response
Saving calc.div.req.xml sample SOAP/XML request
Saving calc.div.res.xml sample SOAP/XML response
Saving calc.pow.req.xml sample SOAP/XML request
Saving calc.pow.res.xml sample SOAP/XML response
Saving calc.nsmap namespace mapping table
Saving soapClient.c client call stub functions
Saving soapC.c serialization functions
Compilation successful
文件目录如下:
PS C:\Users\soft\Downloads\gsoap-2.8\gsoap\bin\win32> ls
目录: C:\Users\soft\Downloads\gsoap-2.8\gsoap\bin\win32
Mode LastWriteTime Length Name
---- ------------- ------ ---- -a---- 2017-2-10 16:28 498 calc.add.req.xml -a---- 2017-2-10 16:28 509 calc.add.res.xml -a---- 2017-2-10 16:28 498 calc.div.req.xml -a---- 2017-2-10 16:28 509 calc.div.res.xml -a---- 2017-2-10 16:26 24146 calc.h -a---- 2017-2-10 16:28 498 calc.mul.req.xml -a---- 2017-2-10 16:28 509 calc.mul.res.xml -a---- 2017-2-10 16:28 577 calc.nsmap -a---- 2017-2-10 16:28 498 calc.pow.req.xml -a---- 2017-2-10 16:28 509 calc.pow.res.xml -a---- 2017-2-10 16:28 498 calc.sub.req.xml -a---- 2017-2-10 16:28 509 calc.sub.res.xml -a---- 2017-2-10 16:28 83065 soapC.c -a---- 2017-2-10 16:28 11349 soapClient.c -a---- 2017-2-5 11:47 655360 soapcpp2.exe -a---- 2017-2-10 16:28 51382 soapH.h -a---- 2017-2-10 16:28 14449 soapStub.h -a---- 2017-2-5 11:47 1269760 wsdl2h.exe
运行时要加上-I的参数,要不可能会报如下的错误:
** The gSOAP code generator for C and C++, soapcpp2 release 2.8.43
** Copyright (C) 2000-2017, Robert van Engelen, Genivia Inc.
** All Rights Reserved. This product is provided "as is", without any warranty.
** The soapcpp2 tool and its generated software are released under the GPL.
** ----------------------------------------------------------------------------
** A commercial use license is available from Genivia Inc., contact@genivia.com
** ----------------------------------------------------------------------------
Critical error: #import: Cannot open file "soap12.h" for reading.
Hint: use option -I<path> (for example -Igsoap;gsoap/import;gsoap/custom:.)
生成完了接口函数,剩下的就可以随意处理了。
参考地址:https://www.genivia.com/dev.html
http://blog.sina.com.cn/s/blog_4900f3fb0100j94p.html
http://www.voidcn.com/article/p-kgdnskpo-dy.html
http://www.voidcn.com/article/p-fpmhbera-pv.html