Looking for some assistance with this error
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
On the WCF service Service Interface looks like this:
[ServiceContract]
public interface ICSServiceLevel
{
[OperationContract]
[WebInvoke(Method = "POST",
BodyStyle = WebMessageBodyStyle.WrappedRequest,
RequestFormat = WebMessageFormat.Json,
ResponseFormat = WebMessageFormat.Json,
UriTemplate = "getservicelevel")]
List<ServiceLevel> GetServiceLevel(long id);
}
The implementation of the interface:
[ServiceBehavior(AddressFilterMode = AddressFilterMode.Any)]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class CSServiceLevel : ICSServiceLevel
{
public List<ServiceLevel> GetServiceLevel(long id)
{
List<ServiceLevel> retValue;
//...
return (retValue);
}
}
The Web.config for the service role is:
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
<services>
<service behaviorConfiguration="CloudWCFServiceBehavior" name="CSServiceLevel">
<endpoint address="" binding="webHttpBinding" behaviorConfiguration="JsonEndpointBehavior"
contract="Services.ICSServiceLevel" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="CloudWCFServiceBehavior">
<useRequestHeadersForMetadataAddress>
<defaultPorts>
<add scheme="http" port="81"/>
<add scheme="https" port="444"/>
</defaultPorts>
</useRequestHeadersForMetadataAddress>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="JsonEndpointBehavior">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
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"
});
Anybody see what the problem could be? Also, in the definition of the webrole for the service, I do make the endpoint 81