locked
Support for WsHttpBinding RRS feed

  • Question

  • I am trying to get WCF data services working with WsHttpBinding. Based upon other discussions, it looks like that should be supported (where net.tcp is not supported).

    Added the following service host factory:

     

    public class CustomMyServiceHostFactory : MyServiceHostFactory

    {

     

    protected override System.ServiceModel.ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)

     

    //var host = base.CreateServiceHost(serviceType, baseAddresses);

     

    var host = new MyServiceHost(serviceType, baseAddresses);

    host.AddServiceEndpoint(serviceType.GetInterfaces()[0],

     

    new WSHttpBinding(SecurityMode.Message), host.BaseAddresses[0]);

     

     

    return host;

     

    But I keep getting the following error.

    The operation 'ProcessRequestForMessage' could not be loaded because it has a parameter or return type of type System.ServiceModel.Channels.Message or a type that has MessageContractAttribute and other parameters of different types. When using System.ServiceModel.Channels.Message or types with MessageContractAttribute, the method must not use any other types of parameters

    Does this mean that the WCF data services contract does not allow WSHttpBinding?

    I found the following: http://social.msdn.microsoft.com/Forums/en/dataservices/thread/42ab902f-1061-473f-8172-6998809fac41 stating that it's the wrong IRequestHandler, but since I am pulling the interface from the actual service host, I don't see how that could be the problem.

    }

    {

     

    Monday, March 15, 2010 5:20 PM

Answers

  • Hi mrent,

     

    Sorry for the delay.   No, WCF Data Service does not support WsHttpBinding.  It is actually a REST service with a custom OData serializer.   It deals with AtomPub messages. WSHttpBinding by default only supports SOAP messages.

     

    To make WSHttpBinding work against OData, you have to write a custom OData serializer (or at least figure out how to invoke the built-in one). You can, for example, write a message filter that converts the AtomPub data to a SOAP envelop, or use a custom binding with a custom message version (which uses AtomPub messages rather than SOAP). All of these require a lot of work.

     

    If the customer wants to deal with SOAP messages, then he should use a SOAP service, such as a normal WCF SOAP Service, or a WCF RIA Service.

     

    If the customer wants to keep using the AtomPub message, but needs to work against an existing MessageContract class, he can treat the MessageContract class as a normal CLR class, add a DataServiceKey attribute, and use it as a custom data provider for the WCF Data Service.

     

    Have a nice day!

     

     

    Thanks,

    Lingzhi Sun


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Monday, March 29, 2010 7:03 AM
    Moderator

All replies

  • Hi mrent,

     

    Welcome to WCF Data Services forum!

     

    We are currently investigating this issue and will get back to you as soon as possible. 

     

     

    Thanks,

    Lingzhi Sun


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Wednesday, March 17, 2010 1:18 AM
    Moderator
  • Thanks! I figured out that an other potential cause is mixing message contracts with other contracts. Do I introduce a message contract when I switch to WSHttpBinding? I appreciate your time and help.

     

    Wednesday, March 17, 2010 3:00 AM
  • Hi I've the same problem.

    Is there a solution

    Thanks

    Regards
    Thursday, March 18, 2010 3:55 PM
  • It seems like the mixing of messaging contracts with other contracts has been marked as the answer. But that doesn't really resolve the problem. Is WsHttpBinding not supported on purpose? Or is this an issue/broken item?

    Thursday, March 18, 2010 4:08 PM
  • Hi mrent,

     

    Sorry for the delay.   No, WCF Data Service does not support WsHttpBinding.  It is actually a REST service with a custom OData serializer.   It deals with AtomPub messages. WSHttpBinding by default only supports SOAP messages.

     

    To make WSHttpBinding work against OData, you have to write a custom OData serializer (or at least figure out how to invoke the built-in one). You can, for example, write a message filter that converts the AtomPub data to a SOAP envelop, or use a custom binding with a custom message version (which uses AtomPub messages rather than SOAP). All of these require a lot of work.

     

    If the customer wants to deal with SOAP messages, then he should use a SOAP service, such as a normal WCF SOAP Service, or a WCF RIA Service.

     

    If the customer wants to keep using the AtomPub message, but needs to work against an existing MessageContract class, he can treat the MessageContract class as a normal CLR class, add a DataServiceKey attribute, and use it as a custom data provider for the WCF Data Service.

     

    Have a nice day!

     

     

    Thanks,

    Lingzhi Sun


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Monday, March 29, 2010 7:03 AM
    Moderator
  • Hi mrent,

     

    Sorry for the delay.   No, WCF Data Service does not support WsHttpBinding.  It is actually a REST service with a custom OData serializer.   It deals with AtomPub messages. WSHttpBinding by default only supports SOAP messages.

     

    To make WSHttpBinding work against OData, you have to write a custom OData serializer (or at least figure out how to invoke the built-in one). You can, for example, write a message filter that converts the AtomPub data to a SOAP envelop, or use a custom binding with a custom message version (which uses AtomPub messages rather than SOAP). All of these require a lot of work.

     

    If the customer wants to deal with SOAP messages, then he should use a SOAP service, such as a normal WCF SOAP Service, or a WCF RIA Service.

     

    If the customer wants to keep using the AtomPub message, but needs to work against an existing MessageContract class, he can treat the MessageContract class as a normal CLR class, add a DataServiceKey attribute, and use it as a custom data provider for the WCF Data Service.

     

    Have a nice day!

     

     

    Thanks,

    Lingzhi Sun


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.

    Thanks for your instruction! Nice writing.
    Tuesday, October 19, 2010 7:23 AM