0

我正在使用带有 g++ 和 qmake 的 gsoap 编译程序。经过数小时的工作后,我从编译器中得到了这个错误:

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

查看 中的文件/usr/share/gsoap/import,我可以看到其中有很多@s:

的一部分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;

我无法理解@代码中的内容,我认为 C++ 中没有这样的东西。

有大佬帮忙吗?!谢谢。

编辑: 其中还有其他奇怪的东西。另一个编译错误是:

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

看一下源文件,结构定义中有很多这样的东西:

/// "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.
};

我不知道如何解释属性名称后的数字。


答案摘要:

正如 mpromonet 所提到的,/usr/share/gsoup/import类似ds.hwsse.h不是 C/C++ 代码的文件不应使用 C/C++ 编译器进行编译。从他们的标题中的评论可以理解:

生成:wsdl2h -cuxy -o ds.h -t WS/WS-typemap.dat WS/ds.xsd

相反,它们应该被交给像这样gsoap调用的工具soapcpp2

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

然后的问题是我已经在编译另一个onvif.h用 soapcpp2 调用的文件,并且该工具无法同时处理两个文件。然后(再次感谢 mpromonent)事实证明,wsse.h在原始文件中导入第二个文件onvif.h可以解决问题。换句话说,将以下行添加到onvif.h

#import "wsse.h"

起初,对我来说,网络上似乎没有太多信息,但在平均文件中,我发现这个指南非常有用:

http://www.genivia.com/dev.html

4

1 回答 1

1

/usr/share/gsoap/import/ds.h文件由wsdl2h. 在评论中,您应该会看到如下内容:

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

这不是 C/C++ 包含,它应该由 gSOAP 工具处理soapcpp2

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

这将生成您应该与项目一起编译的包含和源文件。

为了使用wsse插件,您应该附加到使用 wsdl2h 生成的文件中:

#import "wsse.h"
于 2015-12-14T21:57:03.073 回答