title: Azure 405 Method not allowed error...
body: <p>Looking for some assistance with this error</p>
  
  <p>I have an Azure WCF service that I call from Javascript. However when I call my WCF Service from JavaScript, I get the following error:
   - 405 Method Not Allowed</p>
  
  <p>On the WCF service Service Interface looks like this:</p>
  
  <pre><code>[ServiceContract]
  public interface ICSServiceLevel
  {
      [OperationContract]
      [WebInvoke(Method = "POST",
        BodyStyle = WebMessageBodyStyle.WrappedRequest,
        RequestFormat = WebMessageFormat.Json,
        ResponseFormat = WebMessageFormat.Json,
        UriTemplate = "getservicelevel")]
      List&lt;ServiceLevel&gt; GetServiceLevel(long id);      
  }
  </code></pre>
  
  <p>The implementation of the interface:</p>
  
  <pre><code>[ServiceBehavior(AddressFilterMode = AddressFilterMode.Any)]
  [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
  public class CSServiceLevel : ICSServiceLevel
  {
      public List&lt;ServiceLevel&gt; GetServiceLevel(long id)
      {
          List&lt;ServiceLevel&gt; retValue;
          //...
          return (retValue);
      }
  }
  </code></pre>
  
  <p>The Web.config for the service role is:</p>
  
  <pre><code> &lt;system.serviceModel&gt;
       &lt;serviceHostingEnvironment aspNetCompatibilityEnabled="true"/&gt;
           &lt;services&gt;
               &lt;service behaviorConfiguration="CloudWCFServiceBehavior" name="CSServiceLevel"&gt;
                   &lt;endpoint address="" binding="webHttpBinding" behaviorConfiguration="JsonEndpointBehavior"
      contract="Services.ICSServiceLevel" /&gt;
                   &lt;endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /&gt;
               &lt;/service&gt;
          &lt;/services&gt;
          &lt;behaviors&gt;
            &lt;serviceBehaviors&gt;
              &lt;behavior name="CloudWCFServiceBehavior"&gt;
                  &lt;useRequestHeadersForMetadataAddress&gt;
                      &lt;defaultPorts&gt;
                          &lt;add scheme="http" port="81"/&gt;
                          &lt;add scheme="https" port="444"/&gt;
                      &lt;/defaultPorts&gt;
                  &lt;/useRequestHeadersForMetadataAddress&gt;
               &lt;serviceMetadata httpGetEnabled="true"/&gt;
            &lt;serviceDebug includeExceptionDetailInFaults="true"/&gt;
         &lt;/behavior&gt;
    &lt;/serviceBehaviors&gt;
  
    &lt;endpointBehaviors&gt;
      &lt;behavior name="JsonEndpointBehavior"&gt;
        &lt;webHttp/&gt;
      &lt;/behavior&gt;
    &lt;/endpointBehaviors&gt;
  &lt;/behaviors&gt;
  
  
  And finally the way I call it is :
  
  
  var data = '{ "id" : -1}';
  $.ajax({
      data: data, cache: false, success: populateCustomerGrid,
      type: "POST", dataType: "json", contentType: "application/json",
      url: "http://mydomain.cloudapp.net:81/CSServiceLevel.svc/getservicelevel"
  });
  </code></pre>
  
  <p>Anybody see what the problem could be? Also, in the definition of the webrole for the service, I do make the endpoint 81</p>