我有一个自托管服务器(Windows 服务),它同时支持 SOAP/RPC(将来可能会消失)和 REST。RESTful GET 按预期工作,但 PUT/POST 给出 405 错误(不支持方法)。我很确定这是我的 app.config 的配置问题,但我对此很陌生,不知道该尝试什么。
下面是我的配置文件。任何帮助将不胜感激......
<system.serviceModel>
<!-- bindings -->
<bindings>
<basicHttpBinding>
<binding name ="soapBinding">
<security mode="None" />
</binding>
</basicHttpBinding>
<webHttpBinding>
<binding name="webBinding" />
</webHttpBinding>
</bindings>
<!-- behaviors -->
<behaviors>
<endpointBehaviors>
<!-- plain old XML -->
<behavior name="poxBehavior">
<webHttp/>
</behavior>
<!-- JSON -->
<behavior name="jsonBehavior">
<enableWebScript />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="DSServerBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="True"/>
</behavior>
</serviceBehaviors>
</behaviors>
<!-- services -->
<services>
<service behaviorConfiguration="DSServerBehavior" name="dsServer.DSServer">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8000/DecisionSupportServer" />
</baseAddresses>
</host>
<endpoint address="soap"
binding="basicHttpBinding"
bindingConfiguration="soapBinding"
contract="dsServer.IDSServer" />
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
<endpoint address="rest"
binding="webHttpBinding"
bindingConfiguration="webBinding"
behaviorConfiguration="poxBehavior"
contract="dsServer.IDSServer" />
</service>
</services>
</system.serviceModel>