Question

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.

Thanks

Edit:
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.

Was it helpful?

Solution

You are using basicHttpBinding. Change it to webHttpBinding.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top