title: JQuery/WCF without ASP.NET AJAX:
body: <p>I am proper struggling getting that &quot;magic&quot; moment when WCF is configured nicely and jQuery is structuring its requests/understanding responses nicely.</p>
  <p>I have a service:</p>
  <pre><code>&lt;%@ ServiceHost Language=&quot;C#&quot; Debug=&quot;true&quot; Service=&quot;xxx.yyy.WCF.Data.ClientBroker&quot; Factory=&quot;System.ServiceModel.Activation.WebScriptServiceHostFactory&quot;  %&gt;
  </code></pre>
  <p>This was recommended by the man <a href="http://www.west-wind.com/WebLog/posts/310747.aspx" rel="nofollow noreferrer">Rick Strahl</a> to avoid having to define the behaviours within Web.config.</p>
  <p>My interface for the WCF service sits in another assembly:</p>
  <pre><code>namespace xxx.yyy.WCF.Data
  {       
      [ServiceContract(Namespace = &quot;yyyWCF&quot;)] 
      public interface IClientBroker
      {
          [OperationContract]         
          [WebInvoke(Method=&quot;POST&quot;,BodyStyle=WebMessageBodyStyle.Wrapped,ResponseFormat=WebMessageFormat.Json)]
          IClient GetClientJson(int clientId);    
      }
  }
  </code></pre>
  <p>The concrete service class is:</p>
  <pre><code>namespace xxx.yyy.WCF.Data
  {
      [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
      class ClientBroker : IClientBroker 
      {
          public IClient GetClientJson(int clientId)
          {
              IClient client=new Client();
  
              // gets and returns an IClient
              return client;
          }
      }
  }
  </code></pre>
  <p>My IClient is an Entity Framework class so is decorated with DataContract/DataMember attributes appropriately.</p>
  <p>I am trying to call my WCF service using the methods outlined on Rick Strahl's blog at <a href="http://www.west-wind.com/weblog/posts/324917.aspx" rel="nofollow noreferrer">http://www.west-wind.com/weblog/posts/324917.aspx</a> (the &quot;full fat&quot; version). The debugger jumps into the WCF service fine (so my jQuery/JSON is being understood) and gets the IClient and returns it. However, when I return the response, I get various useless errors. The errors I am getting back don't mean much.</p>
  <p>I am using POST.</p>
  <p>Am I right to be using an Interface instead of a concrete object? As it does get into the WCF service, it does seem to be the encoding of the result that is failing.</p>
  <p>Does anyone have any ideas?</p>