WS-Discovery & gSOAP set up in VS2013 - web-services

My overarching goal is to create a small ONVIF client for getting camera information in either C or C++.
gSOAP seemed like a good candidate and first thing I wanted to achieve was to make a small console application which would list the addresses of a bunch of cameras I have on my network using WS-Discovery, something I've done before with a little .NET application.
The problem is I'm stumbling at the first hurdle and I'm a touch confused as to what I'm supposed to be doing. I started out by doing the following:
wsdl2h.exe -o WSDiscovery.h WS-Discovery.wsdl http://www.w3.org/2006/03/addressing/ws-addr.xsd
soapcpp2.exe -i -C -Iimport WSDiscovery.h -d output
,
I then made a project from the resulting soapC.cpp stdsoap2.cpp soapH.h soapStub.h. Adding in threads.h wsaapi.h wsddapi.h threads.c wsaapi.c wsddapi.c from gsoap
This doesn't compile however giving:
wsaapi.h(134): error C2061: syntax error : identifier 'wsa__FaultSubcodeValues'
I think I'm going very wrong here and I'm confused about exactly what a 'plugin' is in the context of gSOAP (my experience with external libraries like this is extremely limited and I have no real formal training in CS). Am I just supposed to be doing what I'm doing now with the wsdd files or are they supposed to be used as part of the soapcpp2.exe process? Am I actually supposed to be using wsdl2h.exe if I just want WS-Discovery?
I can't really make sense of the documentation and don't understand how I'm supposed to get this working. Some help would be greatly appreciated so I can crack on with the actual hard part!

I guess the problem is coming from usage of WS-Adressing plugins (wsaapi.h/.c) with http://www.w3.org/2006/03/addressing/ws-addr.xsd schema.
gSOAP contains the wsdl2h generated file that could be used by WS-discovery plugins (wsddapi.h/.c).
[GSOAP_DIR]/import/wsdd10.h for WS-Discovery 1.0 2005 that use WS-Adressing 2004/08
[GSOAP_DIR]/import/wsdd.h for WS-Discovery 1.1 2009 that use WS-Adressing 2005/08
As ONVIF use WS-Discovery 1.0 you could generate discovery implementation using :
soapcpp2 -Cx [GSOAP_DIR]/import/wsdd10.h -I [GSOAP_DIR]/import -d output
Next you should be able to build your project including wsddapi.c wsaapi.c soapClient.cpp soapC.cpp
You can find some of my experiments from github ws-discovery

Related

How to I tell em++ to find WS2tcpip.h

Trying to make a whois tcp lookup that directly queries verisign via port 43. Got it to work in command line + visual studio community 2017.
When I try to use em++ to compile it, I get an error.
C:\Users\Samuel Walker\source\repos\Barebones_Client\Barebones_Client>em++ -O3 --emrun -s WASM=1 -o main.html main.cpp
main.cpp:3:10: fatal error: 'WS2tcpip.h' file not found
#include <WS2tcpip.h>
^~~~~~~~~~~~
1 error generated.
ERROR:root:compiler frontend failed to generate LLVM bitcode, halting
I'm using WS2tcpip.h for the script. It's essential, but yeah still entirely new to C++ and following guides and snippets online. Is this a matter of somehow telling enscripten to know where windows header files are or am I completely off?
You cannot. WS2tcpip.h is part of the Windows API, which is not available in the browser.
You can make HTTP requests from JavaScript, but there are no generic sockets to be able to make requests using the WHOIS protocol. You will need to contact a web server that offers an API for making WHOIS requests. Also see this question and its answers:
Whois with JavaScript

How to run gSOAP code generator without internet connection?

I am trying to generate code using wsdl2h/soap2cpp for the onvif media WSDL http://www.onvif.org/onvif/ver10/media/wsdl/media.wsdl. This wsdl have some dependencies.
Reading the gSOAP FAQ http://www.cs.fsu.edu/~engelen/soapfaq.html, I finally extract the needed namespaces in following typemap.dat
trt = "http://www.onvif.org/ver10/media/wsdl"
tt = "http://www.onvif.org/ver10/schema"
wsnt = "http://docs.oasis-open.org/wsn/b-2"
wsrfbf = "http://docs.oasis-open.org/wsrf/bf-2"
wstop = "http://docs.oasis-open.org/wsn/t-1"
xop="http://www.w3.org/2004/08/xop/include"
wsa5 = <http://www.w3.org/2005/08/addressing>
With this mapping the gSOAP code generator run correctly :
wsdl2h media.wsdl
soapcpp2 -2ix media.h -I /usr/share/gsoap/import
But this need to have an internet connection. I would like to build with files that are stored locally.
In the wsdl2h help there is an option that looks interesting :
-i don't import (advanced option)
So I download what was downloaded by wsdl2h :
http://www.onvif.org/onvif/ver10/schema/onvif.xsd
http://docs.oasis-open.org/wsn/b-2.xsd
http://www.w3.org/2004/08/xop/include
http://docs.oasis-open.org/wsrf/bf-2.xsd
http://docs.oasis-open.org/wsn/t-1.xsd
And next run
wsdl2h -im media.wsdl onvif.xsd b-2.xsd include bf-2.xsd t-1.xsd
soapcpp2 -2ix media.h -I /usr/share/gsoap/import
But this fails with this kind of output :
** The gSOAP code generator for C and C++, soapcpp2 release 2.8.7
** Copyright (C) 2000-2011, Robert van Engelen, Genivia Inc.
** All Rights Reserved. This product is provided "as is", without any warranty.
** The soapcpp2 tool is released under one of the following two licenses:
** GPL or the commercial license by Genivia Inc.
media.h(164): syntax error
media.h(163): Syntax error: declaration expected
media.h(173): syntax error
...
In media.h the code reference strucure coming from ws-addressing. Next I tried different things importing more xsd but I did not find a way to resolve the missing dependencies.
Perhaps this is not the proper way to build from local file. Anyway I would like to avoid any modification in the wsdls and xsd files. An alternative could be a catalog to map the remote url to local url (like Apache CXF) but I did not find anything like this in gSOAP documentation.
Thanks for sharing your experiences.
I found only partial documentation of the typemap.dat format from gSOAP site http://www.cs.fsu.edu/~engelen/soapdoc2.html. However I noticed that some namespace definition use <url> instead of "url".
After some tries, this give a solution to the problem, defining namespace enclosed inside <>.
So I modified the typemap.dat like this :
trt=<http://www.onvif.org/ver10/media/wsdl>
tt=<http://www.onvif.org/ver10/schema>
wsnt=<http://docs.oasis-open.org/wsn/b-2>
wsrfbf=<http://docs.oasis-open.org/wsrf/bf-2>
wstop=<http://docs.oasis-open.org/wsn/t-1>
xop=<http://www.w3.org/2004/08/xop/include>
wsa5=<http://www.w3.org/2005/08/addressing>
Then it is possible to generate code from the media.wsdl without connecting to internet :
wsdl2h media.wsdl onvif.xsd b-2.xsd include bf-2.xsd t-1.xsd
soapcpp2 -2ix media.h -I /usr/share/gsoap/import

Gsoap 2.8.17 undefined reference to 'soap_initialize'

I'm new with gsoap and trying to build a multithreading server standalone, reading the problems with the ubuntu package with memory by default, I installed the last version 2.8.17. Reading some posts here I tried the example posted by jackson
gSOAP Multithreading
so ... I execute soapcpp2 -i -S calc.h
and then when I compile this, I get this message :
In function CalculatorService::reset()':
soapCalculatorService.cpp:(.text+0x24f): undefined reference tosoap_initialize'
I've been looking where this method is declared but no look, hope you can give me some ideas! . Thanks in advance.
I guess you forgot to link with -lgsoap++ that define soap_init (or soap_initialiaze) depending on the gSOAP version.
The command to compile and link command could be something like :
g++ calc.cpp soapCalculatorService.cpp soapC.cpp -l gsoap++

Issues compiling vmware web api client code into useable objects

I'm using vmware's web application api in an attempt just to simply retrieve the fields in the "ServiceContent" object. There is an example of how this should be accomplished located at the vmware forum. The example contained there compiles fine for me however I get segfaults when running the simple example - specifically the trace goes back to the soap_serializeheader() function (I believe these are defined in stdsoap2.cpp). My problem is that I do not know how to avoid this segfault and have no idea why this is occurring (as I am following the example almost word for word). I am using OS X tool chain (gcc version 4.0.1 (Apple Inc. build 5465) ) combined with (gsoap release 2.7.16). I tried gsoap 2.8 but got the same result. Below is the procedure I used to get to where I am now.
These are the commands I used to parse the wsdl:
wsdl2h -o vim25.h vimService.wsdl
Once this is parsed, I compiled using the following command:
soapcpp2 -x -C -pvsp vim25.h -I/place/where/stlvector.h/is
this generates files vspC.cpp, vspClient.cpp, and vspVimBindingProxy.cpp. Internally these files have the same prefixes for functions (i.e. ns1/ns2 etc) so my calls are the same as those in the example.
This is the command I am using to compile vspC.cpp and vspClient.cpp:
g++ -DWITH_COOKIES -DWITH_OPENSSL -c vspC.cpp
g++ -DWITH_COOKIES -DWITH_OPENSSL -c vspClient.cpp
This is the command I use to compile stdsoap2.cpp (if I do not compile with -DWITH_NONAMESPACES I get an error about an undefined symbol "_namepspaces" when I link everything):
g++ -DWITH_COOKIES -DWITH_OPENSSL -DWITH_NONAMESPACES -c stdsoap2.cpp
I then link everything together with the test code (again this is copied almost identically from the example, just with the changes to correctly refer to the files I created):
g++ -DWITH_COOKIES -DWITH_OPENSSL vspC.o vcpClient.o stdsoap2.o testcase.cpp -lssl -lcrypto -o doesntwork
This compiles correctly, but of course fails to run. I read about an OS X user in this vmware forum post who was also having trouble. It appears the gsoap guide says you cannot use stdsoap2.cpp's header and fault serialization codes, and you must compile them separately. The user in the OS X post seems to have done this, however I am not sure how to incorporate them into my test file (he creates the empty env.h file and then compiles it with soap2cpp) - if I include the envH.h file i get about naming conflicts with vspH.h. So a second question would be how do I use soap2cpp to compile all the stubs correctly so that there are not namespace conflicts (which is what I appear to be encountering).
I will not provide the source, as it is displayed at the first vwmare forum link by user stumpr. I do not believe the issue is in the source, but in the way I have used either wsdl2h, soap2cpp, or some incorrect combination of flags during compilation with g++.
Thanks for taking a look, and hopefully some one can resolve the issue!
EDIT I think I may have solved this - by using a 64bit system (and one with more memory). I tried compiling with -m32 on the X.6 and it was not able to do it (complaining about memory issues).
Hopefully someone will stumble upon this and be happy to know the answer.

how to do cryptography (digital signature)in linux

I have done PKCS_7_ASN_ENCODING | X509_ASN_ENCODING in windows using wincrypt and I have to verify signature in linux. Can anyone tell by about good light crypto api on linux.
On searching I found http://home.gna.org/cryptodev-linux/ and on compiling it i am getting this error crypto/hash.h: No such file or directory
This error occurs because you don't have the kernel headers for your system/kernel, therefore when you try to compile, it's unable to find those headers.
More on your end goal, do you want to validate whether a certificate is signed by someone else's certificate?
If so, and if you're open to use OpenSSL, take a look at this answer.
NSS
I would either go with GPG (it also has its own API, just look on the side) or Beecrypt which is probably a little easier to understand but not as complex in its functionality