Making a client application with C++, GSOAP, and Onvif - c++

I am using Visual Studio and GSOAP 2.8.15 to create a C++ Onvif client.
I have run these commands to create source code:
> wsdl2h -P -x -o onvif.h http://www.onvif.org/onvif/ver10/device/wsdl/devicemgmt.wsdl
> soapcpp2 -i -C -IC:\gsoap-2.8.15\gsoap;C:\gsoap-2.8.15\gsoap\import onvif.h
Then I put these files in my MSVC solution:
duration.h/.cpp
soapH.h/soapC.cpp
stdsoap2.h/.cpp
I added this file to the directory but not to the solution:
soapStub.h
I added this as a #define to the compilation:
WITH_NONAMESPACES
I added this include to the main file of my program:
#include "soapDeviceBindingProxy.h"
This gives me a DeviceBindingProxy object, but I don't know what to do with it. I want to connect to an Onvif camera at a known ip address and request information about the device.
The GSOAP examples aren't specific to Onvif, and the Onvif pseudo-code examples aren't specific to GSOAP. Any help would be appreciated.

Just open the definition of DeviceBindingProxy object (or even better: run a doxygen on the gSoap-generated source files and enjoy comfortable HTML documentation).
It should contain a separate method for each action the service provides, named exactly as per service definition.
Each of the methods should take two parameters: request & response (their types are pointers to gSoap-generated structures: see their definition/documentation for details).
All you need to do is create instances of request & response, fill the request, pass pointers to both to this method and harvest the data from (already parsed) response.

Related

gSOAP soapcpp2 #import: Cannot open file “soap12.h” for reading

I'm in the process of moving from gSOAP 2.7 to 2.8.
soapcpp2 is returning the error "#import: Cannot open file “soap12.h” for reading."
I've found a similar post called "#import: Cannot open file “soap12.h” for reading gSoap in VS 2010" but my situation does not seem to be the same. In that case the application was including the .h file generated by wsdl2h and causing an error that caused the developer to change his wsdl2h options and that caused the error. The solution was to not include that .h file
This is what I did that worked in gSOAP 2.7
wsdl2h -s -t TypeMap.dat -o SOAP.h <multiple WSDL file names>
soapcpp2 -C SOAP.h
The wsdl2h execution gives some warnings that are new to 2.8. They are about multiple bindings being found and being collected as one service. I don't think they are important here
What is this SOAP12.h file it thinks it needs to import. TypeMap.dat does not contain an import like that
The answer is this. gSOAP 2.8 requires the specification of a path to the import library in the gSOAP files in the execution of soapcpp2
This is done with the -I option

Using gSOAP to consume a Web Service from C++

I have followed this page to generate client proxy of Web Service: https://www.genivia.com/doc/soapdoc2.html#tth_sEc1.2
The problem is that what occurs is different from what the document says it should occur.
For instance, this file was generated by "wsdl2h -o WSLipigas.h http_of_wsdl": WSLipigas.h
On the other hand, these files were generated by "soapcpp2 -i -C -Iimport WSLipigas.h": ns1.nsmap, SoapC.cpp, soapH.h, soapStub.h.
soapcpp2 output is different from what documentation says, even when i am using version 2.8.
When I examined the generated files, I didn't find any class that I can use conveniently.
The only methods i found were of the type "soap_METHOD_VERB_send__ns1__ACTUALFUNCTION" and "soap_METHOD_VERB_send__ns1__ACTUALFUNCTIONResponse"
With that, i don't now how to proceed later on.
Any help will be appreciated.

does wsimport depend on the original source of the wsdl?

I'm learning about wsimport. In the examples I've seen, they show how to generate the wsdl from the server code, and then, how to use wsimport on the wsdl to generate the java client stubs. Does this imply that in order to use wsimport on the wsdl file, the wsdl file must need to have been originally created using jax-ws? Or should it work on any wsdl file?
The reason why I'm asking is because I get an error when I run the command:
"C:\Program Files\Java\jdk1.8.0_25\bin\wsimport" -s . http://developer.ebay.com/webservices/latest/ebaySvc.wsdl
I get [ERROR] unexpected <ws:any>
I'm still new at this, so I'm not sure if I'm doing something wrong, or if there's something wrong with the WSDL?
In principle it works with any wsdl (as long as it follows the standard). Have you tried to download it locally first, in case it wasn't obtained correctly remotely.

gsoap and implementing c++ webservices

im implementing c++ webservices. i've installed gsoap as i've found that its popular toolkit for c++ webservices. however, im a little confuse in using gsoap.
basically i've got existing c++ codes and i want to use it as webservices. i read the tutorial from gsoap and its instructions are as follows:
1) use the following command and generate the header file with a wsdl file (im using the sample proj "hello" from gsoap):
wsdl2h -o -s h.h h.wsdl
2) with the hello.h, i run the following command to generate a lists of files as follows:
soapcpp2 hello.h
this generate a list of files: RECEV.log, Service.hello.req.xml....soapC.cpp, soapClient.cpp, soapClientLib.cpp, soapH.h,soapServer.cpp,soapServerLib.cpp,soapStub.h,TEST.log
it seems that i have to first generate a c++ header file from a wsdl file. but what if i have existing projects with existing .h and .cpp files. how can i turn them into a webservice?

Files missing with soapcpp2 version 2.8.1

I have a application that must communicate using SOAP with a SmartServer, which is a embedded device. The SOAP messages it accepts are without the namespaces but gSAOP sends them with namespaces. So they look like this:
<ns3:List>
<ns3:iLonItem>
<ns3:xSelect></ns3:xSelect>
</ns3:iLonItem>
</ns3:List>
Instead of this:
<List>
<iLonItem>
<xSelect></xSelect>
</iLonItem>
</List>
I first tried changing the qualified in the WSDL and XSD files to unqualified and then regenerating the files, and changing unqualified to qualified. But the best what i got is
<ns3:List>
<iLonItem>
<xSelect></xSelect>
</iLonItem>
</ns3:List>
Which looks better, but still the lists are with the namespaces.
Then I found this site stating that I must use the SOAP_XML_DEFAULTNS option, so I tried. This didn't work in the beginning but then I found out I have to use version 2.8.1 instead of 2.7.9l-0.2 (the standard version of Debian). So I uninstall-ed the Debian version and downloaded 2.8.1 and copied the files. But now when i try to generate files with soapcpp2 the following files are missing: soapClient.cpp, soapClientLib.cpp, soapProxy.h and a lot of *.req.xml and *.res.xml files. I need especially the soapClient.cpp file to compile my project.
I tried the standard binarys from the gsoap/bin directory and rebuilding the src and wsdl files from the gsoap directory as described in INSTALL.txt , but none of this works as I want to.
Can anybody help me a bit further?
For if it matters I'm using Debian Linux version 5.0.8 (Lenny, old-stable) 32 bits.
Regarding your question:
...the following files are missing: soapClient.cpp, soapClientLib.cpp, soapProxy.h and a lot of *.req.xml and *.res.xml files. I need especially the soapClient.cpp file to compile my project.
According to the link http://www.cs.fsu.edu/~engelen/soapdoc2.html#tth_sEc8 (see section 9.1)
it looks as if you may have used the wrong option set for the call to soapcpp2. Are you sure you did not specify "Generate server-side code only" by using the -S switch? For client side only you would use the -C. For both server and client side files, no switches are required. Also, generating the proxy files requires that -i be used.
Hope this helps,
Ryyker