我设置了一个配置的 URL 端点(使用 wcf 和 POST 方法),以便在我的客户端发生某些事情时触发。当请求的内容类型设置为application/json时它运行良好,但当它设置为我的客户想要使用的application/json+hal时它不起作用。我的问题是如何处理这件事以及我必须改变什么。这是我的方法在接口中的定义:
[WebInvoke(Method = "POST", UriTemplate = "/payload", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare)]
string payload(requestpayload jsondata);
我更新了我web.config
的考虑@carlosfigueira 的建议:
<services>
<service behaviorConfiguration="RestServiceBehavior" name="RestRaw.RestService">
<endpoint address="http://mywebsite.com/RestService.svc" binding="customBinding" bindingConfiguration="RawReceiveCapable" contract="RestRaw.IRestService" behaviorConfiguration="Web">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="RestServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="Web">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<customBinding>
<binding name="RawReceiveCapable">
<webMessageEncoding webContentTypeMapperType="RestRaw.JsonHalMapper, RestRaw" />
<httpTransport manualAddressing="true" />
</binding>
</customBinding>
但是,我得到了这个:
500 System.ServiceModel.ServiceActivationException
请有任何想法