I have a WCF service that takes as a parameter a string value "name". This service interface looks like this...
[ServiceContract(Name = "ContactLookup", Namespace = "Search")]
public interface IAjaxResultSearcherService
{
[OperationContract]
[WebGet(RequestFormat = WebMessageFormat.Json)]
Result[] SearchResultsWithNameLike(string name);
}
The service is exposed to using the following configuration...
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
<behaviors>
<serviceBehaviors>
<behavior name="AjaxServiceBehavior">
<serviceDebug
includeExceptionDetailInFaults="true"
httpHelpPageEnabled="true"/>
<serviceMetadata httpGetEnabled="true" httpGetUrl=""/>
<serviceCredentials>
<serviceCertificate findValue="localhost"
storeLocation="LocalMachine"
storeName="My" x509FindType="FindBySubjectName"/>
</serviceCredentials>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="JsonBehavior">
<enableWebScript/>
</behavior>
</endpointBehaviors>
</behaviors>
<services>
<service name="HelloIndigo.AjaxResultSearcherService"
behaviorConfiguration="AjaxServiceBehavior">
<endpoint address="json"
binding="webHttpBinding"
behaviorConfiguration="JsonBehavior"
contract="Contract.IAjaxResultSearcherService" />
</service>
</services>
</system.serviceModel>
My .svc file uses the WebScriptServiceHostFactory. This seems to be working, meaning that I can connect to the service from my jquery client, but even though I set the parameter value via the ajax call, when the message gets to the service implementation, the parameter value is null.
I am calling the service via jquery like so...
$.ajax({
url: url,
data: { "name":"test" },
type: "GET",
processData: false,
contentType: "application/json",
timeout: 10000,
dataType: "text",
success: function(res) {
alert('function successful! returned: ' + res.toString());
},
error: function(xhr) {
alert('an error occurred: ' + xhr.responseText);
}
});
I get no errors from the service call, but when I debug the process, the parameter value is null. Why won't WCF pass parameter values like I expect?
Thanks for the help.