I was experiencing the same exception as this when trying to combine two services; one which used a SOAP endpoint and the other which a REST endpoint.
I think the issue is that WCF doesn't seem to like seeing operations which use MessageContract
in the same ServiceContract
as a REST operation. So the way I got around this was by splitting the contracts in two and then having the REST endpoint only implement the WebGet
operation as follows:
[ServiceContract]
public interface IExampleSoapService : IExampleRestService
{
[OperationContract]
void SomeSoapOperation(ExampleMessageContract message);
}
[ServiceContract]
public interface IExampleRestService
{
[OperationContract]
[WebGet(UriTemplate = "/{id}", RequestFormat = WebMessageFormat.Xml, ResponseFormat = WebMessageFormat.Xml, BodyStyle = WebMessageBodyStyle.Bare)]
void SomeRestOperation(int id);
}
And then in configuration:
<services>
<service name="ExampleService">
<endpoint name="ExampleService.BasicHttpBinding"
binding="basicHttpBinding"
contract="IExampleSoapService"
address="soap" />
<endpoint name="ExampleService.WebHttpBinding"
binding="webHttpBinding"
contract="IExampleRestService" />
</service>
</services>
One I split the contracts like this, the issue seems to go away.