title: call WCF method
body: <p>I have WCF service</p>
  
  <p><strong>ITourService.cs</strong></p>
  
  <pre><code>namespace Service
  {
      [ServiceContract]
      public interface ITourService
      {
          [OperationContract]
          [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Xml)]
          double?[] GetPoints(string tourname);
      }
  }
  </code></pre>
  
  <p><strong>Web.config</strong></p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;configuration&gt;
    &lt;system.web&gt;
      &lt;compilation debug="true" targetFramework="4.0" /&gt;
    &lt;/system.web&gt;
    &lt;system.serviceModel&gt;
      &lt;services&gt;
        &lt;service name="TourService.TourService"&gt;
          &lt;endpoint binding="webHttpBinding" contract="TourService.ITourService" behaviorConfiguration="webHttp"/&gt;
        &lt;/service&gt;
      &lt;/services&gt;
      &lt;behaviors&gt;
        &lt;endpointBehaviors&gt;
          &lt;behavior name="webHttp"&gt;
            &lt;webHttp helpEnabled="true"/&gt;
          &lt;/behavior&gt;
        &lt;/endpointBehaviors&gt;
        &lt;serviceBehaviors&gt;
          &lt;behavior&gt;
            &lt;serviceMetadata httpGetEnabled="true"/&gt;
          &lt;/behavior&gt;
        &lt;/serviceBehaviors&gt;
      &lt;/behaviors&gt;
    &lt;/system.serviceModel&gt;
    &lt;system.webServer&gt;
      &lt;modules runAllManagedModulesForAllRequests="true"/&gt;
    &lt;/system.webServer&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>So I used jQuery 1-6-2.min.js and tried to call a method.</p>
  
  <p>Function Start() starts a call</p>
  
  <pre><code>var varType;
  var varUrl;
  var varData;
  var varContentType;
  var varDataType;
  var varProcessData;
  
  function CallService() {
                  $.ajax({
                      type          : varType, //GET or POST or PUT or DELETE verb
                      url           : varUrl, // Location of the service
                      data          : varData, //Data sent to server
                      contentType   : varContentType, // content type sent to server
                      dataType      : varDataType, //Expected data format from server
                      processdata   : varProcessData, //True or False
                      success       : function(msg) {//On Successfull service call
                      ServiceSucceeded(msg);                    
                      },
                      error: ServiceFailed// When Service call fails
                  });
          }
  
  function Start() {
      varType = "POST";
      varUrl = "http://localhost:1592/TourService.svc/GetPoints/";
      varData = '{tourname:customname}'; //tourname=customname doesn't works too and many other variants
      varContentType = "application/json; charset=utf-8";
      varDataType = "xml";
      varProcessData = false; 
      CallService();
  }
  
  function ServiceSucceeded(result) {
      alert(result);
  }
  
  function ServiceFailed(result) {
      alert('Service call failed: ' + result.status + ' ' + result.statusText);
      varType = null;
      varUrl = null;
      varData = null;
      varContentType = null;
      varDataType = null;
      varProcessData = null;
  }
  </code></pre>
  
  <p>However something going wrong.</p>
  
  <p><em>I have a message: Service call failed: 0 error</em></p>
  
  <p>WCF Service works fine, I checked it using standart client on C#</p>
  
  <p>I think a mistake is in an access from javascript to WCF, but I don't know where.</p>