私はJavascriptから呼び出すAzure WCFサービスを持っています。私は、JavaScriptから私の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);
}
インタフェースの実装:
WCFサービスサービスインタフェース上を許可されていません405メソッドは次のようになりますサービスの役割のための
[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"
});
誰かが問題を理解できますか?また、サービスのWebロールの定義では、私はエンドポイントを作る81
インターフェイス定義と呼び出しを取得するように変更しました。しかし、同じエラーが表示されます。 – user1216839