2017-02-16 7 views
0

JSON形式のオブジェクトパラメータをWCFの快適なサービスに渡そうとしています。RestサービスがWebページで「メソッドが許可されていません」を返します

このようなサービス契約コード。

[OperationContract] 
[WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Xml, BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "xml/{id}")] 
string XMLData(string ID); 

このようなweb.configファイル。

<system.serviceModel> 
<services> 
    <service name="RestService.RestServiceImpl" behaviorConfiguration="ServiceBehaviour"> 
    <endpoint address="" binding="webHttpBinding" contract="RestService.IRestServiceImpl" behaviorConfiguration="web"> 
    </endpoint> 
    </service> 
</services> 
<behaviors> 
    <serviceBehaviors> 
    <behavior name="ServiceBehaviour"> 
     <serviceMetadata httpGetEnabled="true"/> 
     <serviceDebug includeExceptionDetailInFaults="false"/> 
    </behavior> 
    </serviceBehaviors> 
    <endpointBehaviors> 
    <behavior name="web"> 
     <webHttp/> 
    </behavior> 
    </endpointBehaviors> 
</behaviors> 
<protocolMapping> 
    <add binding="basicHttpsBinding" scheme="https" /> 
</protocolMapping> 
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" /> 

私は "http://localhost/serviceurl/xml/123" URLでサービスを呼び出すしようとすると、サービスは "メソッド許可されていません" というエラーメッセージが返されました。

答えて

0

私はそれを解決しました。 ファイルから<ProtocolMapping><ServiceHostingEnvironment>タグを削除しなければなりませんでした。

これで問題なく動作します。

関連する問題