c++cgccgsoapwsse

gSOAP files has stray @


I am compiling a program using gSOAP with g++ and qmake. After hours of working around it, I got to this error from the compiler:

/usr/share/gsoap/import/ds.h:89:2: error: stray ‘@’ in program
  @char*     Id;
  ^

Taking a look in the files in /usr/share/gsoap/import, I can see a lot of @s in them:

A part of wsse.h:

/// Element "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd":Reference of complexType "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd":ReferenceType.
/// @brief This element defines a security token reference
/// Imported element _wsse__Reference from typemap WS/WS-typemap.dat.
typedef struct _wsse__Reference
{    @char*                    URI;
    @char*                    ValueType;
} _wsse__Reference;

What are those @ in the code? I think there isn't any such thing in C++.

There are also other weird things in it. Another compile error is:

/usr/share/gsoap/import/ds.h:289: error: expected ';' at end of member declaration
     char* /*base64*/                     PgenCounter                    1; ///< Required element.
                                          ^

Taking a look at the source file, there are a lot of such things in struct definitions:

/// "http://www.w3.org/2000/09/xmldsig#":DSAKeyValueType is a complexType.
struct ds__DSAKeyValueType
{
/// Element G of type "http://www.w3.org/2000/09/xmldsig#":CryptoBinary.
    char* /*base64*/                     G                              0;    ///< Optional element.
/// Element Y of type "http://www.w3.org/2000/09/xmldsig#":CryptoBinary.
    char* /*base64*/                     Y                              1;    ///< Required element.
/// Element J of type "http://www.w3.org/2000/09/xmldsig#":CryptoBinary.
    char* /*base64*/                     J                              0;    ///< Optional element.
/// Element P of type "http://www.w3.org/2000/09/xmldsig#":CryptoBinary.
    char* /*base64*/                     P                              1;    ///< Required element.
/// Element Q of type "http://www.w3.org/2000/09/xmldsig#":CryptoBinary.
    char* /*base64*/                     Q                              1;    ///< Required element.
/// Element Seed of type "http://www.w3.org/2000/09/xmldsig#":CryptoBinary.
    char* /*base64*/                     Seed                           1;    ///< Required element.
/// Element PgenCounter of type "http://www.w3.org/2000/09/xmldsig#":CryptoBinary.
    char* /*base64*/                     PgenCounter                    1;    ///< Required element.
};

I don't know how to interpret the numbers after the property name.


Summary of answer:

As mpromonet mentioned, the files in /usr/share/gsoup/import like ds.h and wsse.h are not C/C++ codes and should not be compiled with a C/C++ compiler. It can be understood from the comment in their headers:

Generated with: wsdl2h -cuxy -o ds.h -t WS/WS-typemap.dat WS/ds.xsd

Instead, they should be handed to the tool coming with gsoap called soapcpp2 like this:

soapcpp2 -I/usr/share/gsoap/import /usr/share/gsoap/import/ds.h

The problem then was that I was already compiling another file called onvif.h with soapcpp2 and the tool can't handle two files together. Then (again, thanks to mpromonent), it turns out that importing the second file, wsse.h, in the original file onvif.h, can fix the problem. In other words, adding the following line to the onvif.h file:

#import "wsse.h"

At first it appears that there are not much information in the web to me, but in the meantime, I found this guide which is pretty helpful:

Getting Started with gSOAP


Solution

  • The /usr/share/gsoap/import/ds.h file is generated by wsdl2h. In comments you should see something like:

    Generated with:
    wsdl2h -cuxy -o ds.h -t WS/WS-typemap.dat WS/ds.xsd
    

    This is not a C/C++ include. It should be processed by the gSOAP tool soapcpp2:

    soapcpp2 -I/usr/share/gsoap/import /usr/share/gsoap/import/ds.h
    

    This will generate include and source files that you should compile with your project.

    In order to use wsse plugin, you should append to the file generated with wsdl2h:

    #import "wsse.h"