【问题标题】:SOAP Action mismatch trying to implement ONVIF server尝试实现 ONVIF 服务器的 SOAP 操作不匹配
【发布时间】:2016-03-07 16:41:24
【问题描述】:

我正在尝试根据http://www.onvif.org/onvif/ver20/ptz/wsdl/ptz.wsdl 的 ONVIF 规范实现 C# WCF 服务器。我已经使用

生成了合约代码
 SvcUtil.exe http://www.onvif.org/onvif/ver20/ptz/wsdl/ptz.wsdl http://www.onvif.org/onvif/ver10/device/wsdl/devicemgmt.wsdl

生成DevicePTZ 接口。然后我创建了生成的接口的实现,并使用ServiceHost 公开它,如下所示:

        serviceHost = new ServiceHost(typeof(OnvifImpl), baseUri);

        serviceHost.AddServiceEndpoint(typeof(Device), new WSHttpBinding(), "device_service");
        serviceHost.AddServiceEndpoint(typeof(PTZ), new WSHttpBinding(), "ptz");

当我将 Onvif Device Manager 2.2.250 (https://sourceforge.net/projects/onvifdm/) 指向我的服务器时,我的服务器中出现异常“消息中指定的 SOAP 操作,'',与 HTTP SOAP 操作,'@ 不匹配987654323@'。”。 Wireshark 显示该请求没有任何 SOAP 标头。但是,据我所知,客户端是针对相同的 WSDL 文件开发的。

恐怕我对 ONVIF、SOAP、Web 服务和 WCF 完全陌生,所以我不知道问题可能出在哪里。我看到了各种修改客户端的建议,但这不是一个选项。

【问题讨论】:

    标签: c# wcf soap onvif


    【解决方案1】:

    答案是使用自定义绑定来移除 WS-Addressing。这就是客户端代码所做的,所以我也这样做来匹配。我不完全确定这是一个“解决方案”还是一个“解决方法”,但它让两个人开始讨论。

    var binding = new CustomBinding(new BindingElement[] { 
        new TextMessageEncodingBindingElement(MessageVersion.Soap12, Encoding.UTF8),
        new HttpTransportBindingElement(),
    });
    
    serviceHost.AddServiceEndpoint(typeof(Device), binding, "device_service");
    serviceHost.AddServiceEndpoint(typeof(PTZ), binding, "ptz");
    

    主要区别在于使用MessageVersion.Soap12 而不是默认的MessageVersion.Soap12WSAddressing10

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多