1. Records in gsoap Development
-T type. dat must be added when using gsoap. Otherwise, the cannot open file ns1.h error may occur.
Type. dat is available in the gsoap toolkit.
Wsdl2h.exe-o xxx. h-t typemap. h XXX. WSDL
The following are the options for wsdl2h:
- -O file name, specifying the output header file
- -N Space prefixes Replace the default NS
- -C: generate pure C code; otherwise, it is C ++ code.
- -S: Do not use STL code
- -T file name, specifying the type map file. The default value is typemap. dat.
- -E: Do not add a namespace prefix to an Enum member.
The type map file is used to specify the conversion rules between types in soap/XML and C/C ++. For example
XSD _ string = | STD: wstring | wchar_t *
Then, the string in soap/XML will be converted to STD: wstring or wchar_t * to better support Chinese characters.
Next we will talk about generating the. cpp file in the. h file.
The options for soapcpp2.exe are as follows:
- -C: only generate client code
- -S: only generate server code
- -L do not generate soapclientlib. C and soapserverlib. c files
- -C generates pure C code; otherwise, it is C ++ code (related to header files)
- -I specifies impORT path (see the preceding Section)
- -X: do not generate xml sample files.
- -I generates C ++ packaging. The client is xxxxproxy. H (. cpp), and the server side is xxxxservice. H (. cpp ).
Here, we usually need to include-X, or a lot of XML files will be generated.
-I option must be included, otherwise soapxxxxbindingservice. cpp and soapxxxxbindingservice. H files will not be generated.
-I options must also be included.-I is followed by the import directory in the gsoap path.
Generally-I E: \ workspace \ onvif \ gsoap-2.8 \ gsoap \ import; E: \ workspace \ onvif \ gsoap-2.8 \ gsoap
For example: soapcpp2.exe-X-I-s media. H-I E: \ workspace \ onvif \ gsoap-2.8 \ gsoap \ import; E: \ workspace \ onvif \ gsoap-2.8 \ gsoap
The following files are usually generated: (media. WSDL is used as an example)
Mediabinding. nsmap
Soapc. cpp
Soaph. h
Soapmediabindingproxy. cpp
Soapmediabindingproxy. h
Soapmediabindingservice. cpp
Soapmediabindingservice. h
Soapstub. h
The above files are parsed as follows:
- The soapstub. h // soap stub file defines the corresponding Remote Call Model in media. h.
- Soapc. c soaph. h // soap sequence and anti-sequence code. It already contains soapstub. H, which must be included on both the server and client.
- Soapclient. c soapclientlib. C // client code. The soapclientlib. c file simply contains soapclient. C and soapc. c soapcpp2 without-I.
- Soapserver. c soapserverlib. C // The server code. The soapserverlib. c file simply contains soapserver. C and soapc. C. soapcpp2 without adding-I.
- Servicesoap. nsmap servicesoap12.nsmap // namespace definition, which must be included on both the server and client.
- Soapservicesoapproxy. h soapservicesoap12proxy. h // C ++ simple packaging of the client (if the header file is pure C code, these two files will not be generated)
Open soapmediabindingservice. h and you will find some virtual functions in it.
In soapmediabindingservice. cpp, we need to implement these virtual functions:
This is an implementation method.
The following content will be further studied ....