2012-03-03 56 views
0

Azure 405メソッドが許可されないエラー...

私は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

答えて

0

なぜGET動詞の代わりにPOST動詞を使用していますか?メソッド名は、それが読み取り専用の冪等元リソースであることを示します。

+0

インターフェイス定義と呼び出しを取得するように変更しました。しかし、同じエラーが表示されます。 – user1216839

0

ポート81と444のバインディングを.csdefファイルに設定しましたか?

また、Fiddlerを接続して、適切なものを送信していることを確認することもできます。通常、JQueryでは、シリアル化されたJSON文字列ではなく、オブジェクトとしてデータを渡すので、問題が発生する可能性があります。

関連する問題