2017-02-16 112 views
0

我想将对象参数作为JSON格式传递给WCF宁静服务。Rest服务返回“方法不允许”在网页上

这样的服务合同代码;

[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”网址的服务,服务返回“不允许的方法”错误消息。

回答

0

我解决了它。我必须从web.config文件中删除<ProtocolMapping><ServiceHostingEnvironment>标记。

现在它的工作很好。

相关问题