1
votes

I am trying to implement a C# WCF server to the ONVIF specifications at http://www.onvif.org/onvif/ver20/ptz/wsdl/ptz.wsdl. I have generated the contract code using

 SvcUtil.exe http://www.onvif.org/onvif/ver20/ptz/wsdl/ptz.wsdl http://www.onvif.org/onvif/ver10/device/wsdl/devicemgmt.wsdl

which generates Device and PTZ interfaces. I then created an implementation of the generated interfaces and expose that using a ServiceHost like this:

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

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

When I point Onvif Device Manager 2.2.250 (https://sourceforge.net/projects/onvifdm/) at my server, I get an exception in my server "The SOAP action specified on the message, '', does not match the HTTP SOAP Action, 'http://www.onvif.org/ver10/device/wsdl/GetScopes'.". Wireshark shows that the request does not have any SOAP header. However, as far as I can tell, the client was developed against the same WSDL files.

I am afraid I am completely new to ONVIF, SOAP, Web services and WCF, so I have no idea where the problem may be. I have seen various suggestions to modify the client, but that is not an option.

1

1 Answers

1
votes

The answer is to use a custom binding to remove WS-Addressing. This is what the client code does, so I do the same to match. I am not entirely sure whether this is a "solution" or a "workaround" but it get the two talking.

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");

The key difference is using MessageVersion.Soap12 instead of MessageVersion.Soap12WSAddressing10 which is the default.