I've been trying out the StandardEndpoints that were introduced as part of .Net 4 and I'm getting the most peculiar of errors.
My code
[ServiceContract]
public interface IAuthenticator
{
[OperationContract]
[WebInvoke(UriTemplate = "AuthenticateUser", Method = "POST", BodyStyle = WebMessageBodyStyle.WrappedRequest, ResponseFormat = WebMessageFormat.Json)]
AuthPacket AuthenticateUser(string Username, string Password, string DeviceId);
}
My web.config
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
</modules>
</system.webServer>
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
<standardEndpoints>
<webHttpEndpoint>
<!--
Configure the WCF REST service base address via the global.asax.cs file and the default endpoint
via the attributes on the <standardEndpoint> element below
-->
<standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true"/>
</webHttpEndpoint>
</standardEndpoints>
</system.serviceModel>
The exception that is driving me crazy!
415 Cannot process the message because the content type 'application/json' was not
the expected type 'text/xml; charset=utf-8'.
I can make the problem going away by going back to the .Net 3.5 standard of declaring each service, but, unless I am mistaken, one of the major upgrades in WCF with .Net 4 was it's ability to handle stuff like this. Am I doing something wrong?