locked
Data Services endpoint with System.Data.Services.IRequestHandler contract throws error RRS feed

  • Question

  • User1776595388 posted

    I am receiving the following error when trying to create an endpoint with the System.Data.Services.IRequestHandler contract

    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.

    I found two other questions with this error (here and here), but neither of them had satisfactory solutions. I pulled the Northwind example and was able to reproduce the problem.

    The simplified web.config file:

    <configuration>
      <system.web>
        <compilation debug="true" targetFramework="4.0">
          <assemblies>
            <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
          </assemblies>
        </compilation>
      </system.web>
      <system.webServer>
        <modules runAllManagedModulesForAllRequests="true" />
      </system.webServer>
      <system.serviceModel>
        <services>
          <service  name="NorthwindService.Northwind">
            <endpoint address="http://localhost:12345/Northwind.svc" binding="basicHttpBinding" contract="System.Data.Services.IRequestHandler" />
          </service>
        </services>
      </system.serviceModel>
    </configuration>
    

    .svc file:

    <%@ ServiceHost Language="C#" Factory="System.Data.Services.DataServiceHostFactory, Microsoft.Data.Services, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Service="NorthwindService.Northwind" %>

    I can get rid of the error by replacing the System.Data.Services.IRequestHandler contract with my own and removing the parameter that the error message is complaining about.

    The built-in ServiceContract, which throws the error:

    namespace System.Data.Services
    {
      [ServiceContract]
      public interface IRequestHandler
      {
        [OperationContract]
        [WebInvoke(UriTemplate = "*", Method = "*")]
        Message ProcessRequestForMessage(Stream messageBody);
      }
    }

    My ServiceContract, which doesn't throw the error (but also doesn't really work since I didn't replicate all of the DataService<T> functionality):

    namespace NorthwindService
    {
      [ServiceContract]
      interface Interface1
      {
        [OperationContract]
        [WebInvoke(UriTemplate = "*", Method = "*")]
        Message ProcessRequestForMessage();
      }
    }

    I'm confused about why the built-in ServiceContract is throwing this error when I try to use it in an endpoint. I'm fairly new to Data Services, so I'm sure I am missing something that seems obvious to everyone else.

    At the end of the day my goal is to use Certificate Authentication, so if there is a way to do that while working around this problem I'm open to it. I've been using this example.


    Thanks,

    Andrea

    Friday, November 30, 2012 12:36 AM

Answers

  • User1776595388 posted

    The answer ended up being to use webHttpBinding instead of basicHttpBinding or wsHttpBinding. Not sure why this works when the other ones don't, but it does.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, February 5, 2013 1:53 PM

All replies

  • User-1000095884 posted

    Hi andreamc,

    According to your description, this issue is related to WCF data service, I will suggest you post the issue in WCF Data Services forum, there are more professionals on this issue, so you can get better support.

    Thanks for your understanding.

    Best Regards.

    Tuesday, December 4, 2012 2:36 AM
  • User1776595388 posted

    Okay, thanks for the tip. I reposted here.

    Tuesday, December 4, 2012 3:36 PM
  • User1776595388 posted

    The answer ended up being to use webHttpBinding instead of basicHttpBinding or wsHttpBinding. Not sure why this works when the other ones don't, but it does.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, February 5, 2013 1:53 PM