Can someone spot the problem with this implementation? I can open it up in the browser and it works, but a call from client side (using both jquery and asp.net ajax fails)
Service Contract
[OperationContract(Name = "GetTestString")]
[WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json
)]
string GetTestString();
In Web.config among other bindings, I have a webHttp binding
<endpoint address="ajax" binding="webHttpBinding" contract="TestService" behaviorConfiguration="AjaxBehavior" />
EndPoint Behavior
<endpointBehaviors>
<behavior name="AjaxBehavior">
<enableWebScript/>
</behavior>
</endpointBehaviors>
</behaviors>
Svc file
<%@ ServiceHost Service="TestService" %>
Client
var serviceUrl = "http://127.0.0.1/Test.svc/ajax/";
var proxy = new ServiceProxy(serviceUrl);
I am then using the approach in http://www.west-wind.com/weblog/posts/324917.aspx to call the service
See Question&Answers more detail:os