title: Jquery: ajax call working and autocomplete not working with WCF
body: <p>I'm using jquery to figure out how to use <code>autocomplete</code>.</p>
  
  <p>I have two input type text <code>example</code>, and <code>example2</code>.
  I just would like to know why it works for ajax call for example textbox and not for autocomplete method on example2 textbox.</p>
  
  <p>Here is the WCF service interface:</p>
  
  <pre><code>[ServiceContract]
  public interface IMyService
  {
      [WebInvoke(Method = "GET",
             RequestFormat = WebMessageFormat.Json,
             ResponseFormat = WebMessageFormat.Json,
             UriTemplate = "getcompletions/q={q}&amp;limit={limit}")]
      List&lt;String&gt; GetCompletions(string q, string limit);
  }
  </code></pre>
  
  <p>When I use ajax call it works nicely:</p>
  
  <pre><code>$(document).ready(function () {
     var url = "http://localhost.:62138/";
     var data = null;
     /*
     //this webservice call works for UriTemplate = "getcompletions/{q}"
     $.ajax({
         url: url + "MyService.svc/GetCompletions/" + $('#example').val(),
         cache: false,
         type: "GET", // http method
         dataType: "json",
         error: function (XMLHttpRequest, status, error) {
              //alert("Error p1 s(" + status + ") e(" + error + ")");
         },
         success: function (msg, arg2, xhr) {
              try {
                  if (msg !== null) {data = msg;}
                  else { alert("msg is null"); }
              } catch (e) { alert("exception: " + e); }}
      }); 
      */
      //but this doesn't work
      $('#example2').autocomplete(url + "MyService.svc/GetCompletions/");
  });
  </code></pre>
  
  <p>Here is the request for <code>autocomplete</code> in fiddler:</p>
  
  <pre><code>GET http://localhost.:62138/MyService.svc/GetCompletions/?q=apri&amp;limit=150&amp;timestamp=1289668676175 HTTP/1.1
  Accept: */*
  Accept-Language: en-US
  User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/5.0; .NET4.0E; .NET4.0C)
  Accept-Encoding: gzip, deflate
  Connection: Keep-Alive
  Host: localhost.:62138
  </code></pre>
  
  <p>Here is the result for <code>autocomplete</code> when fails in fiddler:</p>
  
  <pre><code>HTTP/1.1 404 Not Found
  Server: ASP.NET Development Server/10.0.0.0
  Date: Sat, 13 Nov 2010 17:19:53 GMT
  X-AspNet-Version: 4.0.30319
  Content-Length: 1565
  Cache-Control: private
  Content-Type: text/html; charset=UTF-8
  Connection: Close
  
  &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
    &lt;head&gt;
      &lt;title&gt;Service&lt;/title&gt;
      &lt;style&gt;blabla....&lt;/style&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;div id="content"&gt;
        &lt;p class="heading1"&gt;Service&lt;/p&gt;
        &lt;p&gt;Endpoint not found.&lt;/p&gt;
      &lt;/div&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Here is the web.config</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;configuration&gt;
    &lt;connectionStrings&gt;
      &lt;add name="MyConnectionString" connectionString="Data Source=(local);Initial Catalog=BRAZIL;Integrated Security=True;" providerName="System.Data.SqlClient"/&gt;
    &lt;/connectionStrings&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="YourCompany.Services.MyService" 
                 behaviorConfiguration="anotherBehavior"&gt;
                  &lt;endpoint address="" 
                    behaviorConfiguration="endPointBehavior" 
                    binding="webHttpBinding" 
                    contract="YourCompany.Services.IMyService"/&gt;
  
          &lt;endpoint address="mex"
                    binding="mexHttpBinding"
                    contract="IMetadataExchange" /&gt;
              &lt;/service&gt;
          &lt;/services&gt;
          &lt;behaviors&gt;
              &lt;endpointBehaviors&gt;
                  &lt;behavior name="endPointBehavior"&gt;
            &lt;!--post &lt;enableWebScript/&gt;--&gt;
            &lt;webHttp /&gt;
                  &lt;/behavior&gt;
  
        &lt;/endpointBehaviors&gt;
              &lt;serviceBehaviors&gt;
                  &lt;behavior name="anotherBehavior"&gt;
                      &lt;!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --&gt;
                      &lt;serviceMetadata httpGetEnabled="true"/&gt;
                      &lt;!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information --&gt;
                      &lt;serviceDebug includeExceptionDetailInFaults="true"/&gt;
                  &lt;/behavior&gt;
              &lt;/serviceBehaviors&gt;
          &lt;/behaviors&gt;
          &lt;serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true"/&gt;
      &lt;/system.serviceModel&gt;
      &lt;system.webServer&gt;
          &lt;modules runAllManagedModulesForAllRequests="true"/&gt;
      &lt;/system.webServer&gt;
  &lt;/configuration&gt;
  </code></pre>