Question

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 :

  1. http://www.onvif.org/onvif/ver10/schema/onvif.xsd
  2. http://docs.oasis-open.org/wsn/b-2.xsd
  3. http://www.w3.org/2004/08/xop/include
  4. http://docs.oasis-open.org/wsrf/bf-2.xsd
  5. 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.

Was it helpful?

Solution

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top