gsoap and implementing c++ webservices - c++

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?

Related

Use OpenSSL in Unreal Engine 4.25

I’m trying to use the OpenSSL library included with the engine.
I am using 4.25
In my searches I see people saying to add OpenSSl as a dependency to my project’s build file.
I have seen couple different lines to add to the build file, every one of them causes errors - usually about the the function not being in the current context.
AddEngineThirdPartyPrivateStaticDependencies(Target, “OpenSSL”);
is one example - I believe I read some where to try
ExtraModuleNames.AddRange( new string[] { “OpenSSL”} ); - but that came back with OpenSSL not being a c++ module.
There is another function out there that I forget, but when I tried it, I got the error again about not being in context.
So far only by adding the folder “E:\UE_4.25\Engine\Source\ThirdParty\OpenSSL\1.1.1\Include\Win64\VS2015” to the visual studio c/c++ directory includes list can I just do a regular "#include “openssl/sha.h”. - but when I compiled it, it failed saying that the file didn't exist. Yet I can right click the include in code and view it, as well as intellisense recognizing the classes and functions.
In the solution explorer, I can see the openssl folder under UE4\Source\ThirdParty\openssl - but none of the different openssl version show up and none of the source code files.
In fact, all the ThirdParty libraries just contain one or more build files, or files with a .tps extension.
My ultimate goal is to get access to sha-256 to generate a hash for comparing local custom maps with a server copy - assumption is that if hash is different, server copy is a newer version and is then downloaded.
So my ultimate question is how do I use Unreal's included OpenSSL library.
My problem is that I kept trying to do things in the target file, not the build file - as mentioned in a comment above by Strom.
To enable OpenSSL in an unreal c++ project (I'm using Visual Studio):
Open up your project build file.
Add OpenSSL to the PublicDependencyModuleNames:
using UnrealBuildTool;
public class MyProject : ModuleRules
{
public MyProject(ReadOnlyTargetRules Target) : base(Target)
{
PublicDependencyModuleNames.AddRange(new string[] {
"PhysicsCore",
"OpenSSL"
});
}
}
Close your solution, right click your unreal project .uproject file and choose "Generate Project Files".
Where you want to use openSSL add at the top of your code file in the includes section or in your header file. (in my case I'm using evp as the docs say for sha256).
#define UI UI_ST
THIRD_PARTY_INCLUDES_START
#include "openssl/evp.h"
THIRD_PARTY_INCLUDES_END
#undef UI

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.

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

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.

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