title: Enable WCF Service to use with JSON
body: <p>I have created a wcf service. That is working fine when i am using simply in .net by adding as a webservice. But i want to make it able to use for iPhone app as JSON call. For testing i have used it in .net with JSON but its not working. </p>
  
  <p>i know this kind of question is asked before, i have looked in for this cant find solution for me.</p>
  
  <p>my configuration:</p>
  
  <pre><code>&lt;system.serviceModel&gt;
  &lt;behaviors&gt;
    &lt;serviceBehaviors&gt;
      &lt;behavior name="servicebehavior"&gt;
        &lt;serviceMetadata httpsGetEnabled="true" /&gt;
      &lt;/behavior&gt;
    &lt;/serviceBehaviors&gt;
    &lt;endpointBehaviors&gt;
      &lt;behavior name="endpointBehavior"&gt;
        &lt;enableWebScript /&gt;
        &lt;webHttp defaultBodyStyle="Wrapped" defaultOutgoingResponseFormat="Json" /&gt;
      &lt;/behavior&gt;
    &lt;/endpointBehaviors&gt;
  
  &lt;/behaviors&gt;
  &lt;serviceHostingEnvironment aspNetCompatibilityEnabled="true" /&gt;
  &lt;services&gt;
    &lt;service name="MyService" behaviorConfiguration="servicebehavior"&gt;
      &lt;endpoint address=""
                behaviorConfiguration="endpointBehavior"
                binding="webHttpBinding"
                contract="IMyService" /&gt;
    &lt;/service&gt;
  &lt;/services&gt;
  </code></pre>
  
  <p></p>
  
  <p>interface code:</p>
  
  <pre><code>[ServiceContract]
  public interface IGolfPyramidService
  {
  
  
  
      [WebInvoke(UriTemplate = "/Test", Method = "POST", ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.WrappedRequest)]
      [OperationContract]
      string Test();
  
  }
  </code></pre>
  
  <p>Myservice.cs code:</p>
  
  <pre><code>[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
  public class MyService : IMyService
  {        
      public string Test()
      {
          return "success";
      }
  }
  </code></pre>
  
  <p>i want to make it possible to call the method using url format like :
  <a href="http://example.com/MyService.svc/test">http://example.com/MyService.svc/test</a></p>