I have the interface below that defines my WCF services. Sometimes the ‘parameters’ parameter has been null when this is called. Other times it is not.
[ServiceContract]
public interface IContactRelationshipManager
{
[OperationContract]
[WebInvoke(
Method = "POST",
ResponseFormat = WebMessageFormat.Json,
RequestFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Wrapped)]
void SaveActivityLogEntry(SaveActivityLogEntryParameters parameters);
}
Here is my behaviors section in the app.config (I’m running this as a windows service)
<behaviors>
<endpointBehaviors>
<behavior name="jsonBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="ContactRelationshipManagerBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
Here is my javascript call:
$.ajax(
{
type: "POST",
cache: false,
contentType: "application/json",
url: serviceCallUrl,
data: JSON.stringify(params),
success: callbackHandler
});
The result of JSON.stringify(params) is
“{“parameters”:{“ContactEmailAddress”:”blah@gmail.com”,”LiasonsForContact”:[25],”ActivityLogEntry”:{“Date”:”/Date(1316634966273)/”,”LiasonFK”:25,”TypeFK”:1,”MethodFK”:3,”Description”:”tt”,”ContactFK”:32}}}”
Is there anything that I’m doing wrong here in practice? This works fine all the time in chrome and firefox. I also just tested this with Fiddler while debugging the service and the parameter came back null with Fiddler closed and NOT null when Fiddler is open.
I ended up playing with a bunch of different techniques to get it to work including taking a stream as my function parameter and serializing it inside the function with JSON.NET. That didn’t work either. I finally found this question which led me to believe that it was an NTLM problem. My website uses windows authentication in IIS7 and it calls a WCF service hosted as a windows service. On the server side I changed the security on my webHttpBinding to be as such:
After doing this everything works fine in Internet Explorer