c++ - Gsoap 文件已留在@

标签 c++ c gcc gsoap wsse

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

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

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

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++ 编译器进行编译。从他们header中的注释可以理解:

Generated with: 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

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

#import "wsse.h"

一开始我觉得网络上的信息不多,但在 meanfile 中,我找到了这个指南,它很有帮助:

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

最佳答案

/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"

关于c++ - Gsoap 文件已留在@,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34255637/

相关文章:

c - 在没有 strtok/lexer 的情况下将字符串解析为标记

c++ - 为什么SDL_PollEvent这么慢?

c++ - 在数字常量之前应为 ',' 或 '...'

C - 结构到指针

c++ - 使用具有不同编译器版本的 boost 库

c - 如何找到源代码的依赖关系?

c++ - 创建线程并让 "this"指针从构造函数中逃逸总是安全的吗?

c++ - 传递带有常量作为参数的模板化类

c - 如何知道引用的 fp 当前正在写入哪个文件?

c - select() C lib函数总是返回0