【问题标题】:Error using soapcpp2 with an ONVIF header file generated with wsdl2h ( GSOAP with linux )使用带有 wsdl2h 生成的 ONVIF 头文件的 soapcpp2 时出错(GSOAP with linux)
【发布时间】:2016-06-22 14:30:03
【问题描述】:

我正在尝试使用微控制器在相机端(服务器)上实现 onvif 协议,但还没有任何实现,我正在尝试从 onvif 站点的 wsdl 文件(例如http://www.onvif.org/ver10/device/wsdl/devicemgmt.wsdl)生成头文件和实现文件。

所以我使用 gsoap 和命令 wsdl2h -c -o devicemgmt.h http://www.onvif.org/onvif/ver10/device/wsdl/devicemgmt.wsdl ,它为我生成了 devicemgmt.h,然后当我执行 soapcpp2 devicemgmt.h 时,我有

`devicemgmt.h(12328): syntax error
devicemgmt.h(12327): Syntax error: declaration expected
devicemgmt.h(12330): syntax error
devicemgmt.h(12329): Syntax error: declaration expected
devicemgmt.h(12332): syntax error
devicemgmt.h(12331): Syntax error: declaration expected
devicemgmt.h(12333): syntax error
devicemgmt.h(12339): Syntax error: declaration expected
devicemgmt.h(12342): syntax error
devicemgmt.h(12341): Syntax error: input before ; skipped
devicemgmt.h(12371): syntax error
devicemgmt.h(12370): Syntax error: declaration expected
devicemgmt.h(12373): syntax error
devicemgmt.h(12372): Syntax error: declaration expected
devicemgmt.h(12375): syntax error
devicemgmt.h(12374): Syntax error: declaration expected
devicemgmt.h(12377): syntax error
devicemgmt.h(12376): Syntax error: declaration expected
devicemgmt.h(12415): syntax error
devicemgmt.h(12414): Syntax error: declaration expected
devicemgmt.h(12417): syntax error
devicemgmt.h(12416): Syntax error: declaration expected
Critical error: too many syntactic errors, bailing out`

这是发生错误的头文件部分:

 `/// "http://docs.oasis-open.org/wsn/b-2":NotificationMessageHolderType is a complexType.
struct ns4__NotificationMessageHolderType
{
/// Element reference "http://docs.oasis-open.org/wsn/b-2":SubscriptionReference.
///JUST BELOW THATS THE LINE 12328 WHERE THE ERROR IS 
ns1__EndpointReferenceType*          SubscriptionReference          0;  ///< Optional element.
    /// Element reference "http://docs.oasis-open.org/wsn/b-2":Topic.
        struct ns4__TopicExpressionType*     Topic                          0;  ///< Optional element.
    /// Element reference "http://docs.oasis-open.org/wsn/b-2":ProducerReference.
        ns1__EndpointReferenceType*          ProducerReference              0;  ///< Optional element.
        struct _ns4__NotificationMessageHolderType_Message
        {
    /// TODO: <any namespace="##any" minOccurs="1" maxOccurs="1">
    /// TODO: Schema extensibility is user-definable.
    ///       Consult the protocol documentation to change or insert declarations.
    ///       Use wsdl2h option -x to remove this element.
    ///       Use wsdl2h option -d for xsd__anyType DOM (soap_dom_element).
        _XML                                 __any                         0;   ///< Catch any element content in XML string.
        }                                    Message                        1;  ///< Required element.
    };


    /// Top-level root element "http://docs.oasis-open.org/wsn/b-2":NotificationProducerRP

    /// "http://docs.oasis-open.org/wsn/b-2":NotificationProducerRP is a complexType.
    struct _ns4__NotificationProducerRP
    {
    /// Size of the dynamic array of struct ns4__TopicExpressionType* is 0..unbounded
       $int                                  __sizeTopicExpression          0;
    /// Array struct ns4__TopicExpressionType* of length 0..unbounded
        struct ns4__TopicExpressionType*     TopicExpression                0;
    /// Element reference "http://docs.oasis-open.org/wsn/b-2":FixedTopicSet.
        enum xsd__boolean*                   FixedTopicSet                  0;  ///< Optional element.
    /// Size of the dynamic array of xsd__anyURI* is 0..unbounded
       $int                                  __sizeTopicExpressionDialect   0;
    /// Array xsd__anyURI* of length 0..unbounded
        xsd__anyURI*                         TopicExpressionDialect         0;
    /// Element reference "http://docs.oasis-open.org/wsn/t-1":TopicSet.
        struct ns7__TopicSetType*            ns7__TopicSet                  0;  ///< Optional element.
    };


    /// Top-level root element "http://docs.oasis-open.org/wsn/b-2":SubscriptionManagerRP

    /// "http://docs.oasis-open.org/wsn/b-2":SubscriptionManagerRP is a complexType.
    struct _ns4__SubscriptionManagerRP
    {
    /// Element reference "http://docs.oasis-open.org/wsn/b-2":ConsumerReference.
        ns1__EndpointReferenceType           ConsumerReference              1;  ///< Required element.
    /// Element reference "http://docs.oasis-open.org/wsn/b-2":Filter.
        struct ns4__FilterType*              Filter                         0;  ///< Optional element.
    /// Element reference "http://docs.oasis-open.org/wsn/b-2":SubscriptionPolicy.
        struct ns4__SubscriptionPolicyType*  SubscriptionPolicy             0;  ///< Optional element.
    /// Element reference "http://docs.oasis-open.org/wsn/b-2":CreationTime.
        time_t*                              CreationTime                   0;  ///< Optional element.
    };


    /// Top-level root element "http://docs.oasis-open.org/wsn/b-2":Notify

    /// "http://docs.oasis-open.org/wsn/b-2":Notify is a complexType.
    struct _ns4__Notify
    {
    /// Size of the dynamic array of struct ns4__NotificationMessageHolderType* is 1..unbounded
       $int                                  __sizeNotificationMessage      1;
    /// Array struct ns4__NotificationMessageHolderType* of length 1..unbounded
        struct ns4__NotificationMessageHolderType*  NotificationMessage            1;
    /// TODO: <any namespace="##other" minOccurs="0" maxOccurs="unbounded">
    /// TODO: Schema extensibility is user-definable.
    ///       Consult the protocol documentation to change or insert declarations.
    ///       Use wsdl2h option -x to remove this element.
    ///       Use wsdl2h option -d for xsd__anyType DOM (soap_dom_element).
    /// Size of the array of XML or DOM nodes is 0..unbounded
       $int                                  __size                        0;
        _XML                                 __any                         0;   ///< Catch any element content in XML string.
    };


    /// Top-level root element "http://docs.oasis-open.org/wsn/b-2":UseRaw

    /// "http://docs.oasis-open.org/wsn/b-2":UseRaw is a complexType.
    struct _ns4__UseRaw
    {
    };


    /// Top-level root element "http://docs.oasis-open.org/wsn/b-2":Subscribe

    /// "http://docs.oasis-open.org/wsn/b-2":Subscribe is a complexType.
    struct _ns4__Subscribe
    {
    /// Element ConsumerReference of type "http://www.w3.org/2005/08/addressing":EndpointReferenceType.
        ns1__EndpointReferenceType           ConsumerReference              1;  ///< Required element.
    /// Element Filter of type "http://docs.oasis-open.org/wsn/b-2":FilterType.
        struct ns4__FilterType*              Filter                         0;  ///< Optional element. `

有人可以帮帮我吗?我不知道该怎么做,ns1__EndpointReferenceType 有什么问题,语法错误在哪里?如果要添加任何内容,我应该在 Onvif 标头中添加什么?

【问题讨论】:

  • 您的 typemap.dat 可能有问题,因为我成功运行了您的命令。你看gSOAP FAQ了吗?
  • 你好,我刚看了一下,修改了typemap.dat文件,添加了这里没有的文件,但是总是不成功。我也尝试了 gSOAP FAQ 提出的命令,但它们不起作用,你能帮我理解为什么吗?
  • 当我添加常见问题的命令时,我得到一个空标题,他说他无法打开 typemap.dat
  • 您使用的是旧版本的 gSOAP 吗?使用来自 Ubuntu 15.04 的 gSOAP 2.8.17r,它无需自定义 typemap.dat 即可工作。添加 wsdl2h 可能会有所帮助

标签: c wsdl gsoap onvif


【解决方案1】:

确保使用 gsoap 2.8.x 发行版附带的 typemap.dat。这个typemap.dat 文件包括ONVIF 绑定,还包括EndpointReference 元素的WS-Addressing wsa5.h 绑定:

#import "wsa5.h"
...
class wsnt__NotificationMessageHolderType
{ public:
  /// Element reference "http://docs.oasis-open.org/wsn/b-2:""http://docs.oasis-open.org/wsn/b-2":SubscriptionReference.
    wsa5__EndpointReferenceType*         SubscriptionReference          0;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-01-17
    • 2020-04-12
    • 1970-01-01
    • 1970-01-01
    • 2023-03-08
    相关资源
    最近更新 更多