尋找一些此錯誤的幫助Azure 405方法不允許錯誤...
我有一個Azure WCF服務,我從Javascript調用。然而,當我打電話給我的WCF服務從JavaScript,我收到以下錯誤: - 405不允許的方法
在WCF服務的服務接口看起來是這樣的:
[ServiceContract]
public interface ICSServiceLevel
{
[OperationContract]
[WebInvoke(Method = "POST",
BodyStyle = WebMessageBodyStyle.WrappedRequest,
RequestFormat = WebMessageFormat.Json,
ResponseFormat = WebMessageFormat.Json,
UriTemplate = "getservicelevel")]
List<ServiceLevel> GetServiceLevel(long id);
}
接口的實現:
[ServiceBehavior(AddressFilterMode = AddressFilterMode.Any)]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class CSServiceLevel : ICSServiceLevel
{
public List<ServiceLevel> GetServiceLevel(long id)
{
List<ServiceLevel> retValue;
//...
return (retValue);
}
}
在Web.config的服務作用是:
<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"
});
有人看到了什麼問題?另外,在服務的webrole的定義中,我確定了端點81
更改它以獲取接口定義和調用。但仍然有同樣的錯誤。 – user1216839 2012-03-04 14:52:09