【发布时间】:2011-12-06 10:10:21
【问题描述】:
当请求中包含 content-type:application/xml 标头时,我有一个 REST WCF 服务返回错误请求 (400) 响应。当我删除该标头时,服务会正确响应。
服务定义:
[ServiceContract]
public interface IRestService
{
[OperationContract]
[WebInvoke(UriTemplate = "/methodName", BodyStyle=WebMessageBodyStyle.Bare)]
XElement MethodName(Stream stream);
}
端点配置:
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="webHttp">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<webHttpBinding>
<binding maxReceivedMessageSize="1024000"/>
</webHttpBinding>
</bindings>
<services>
<service name="RestService">
<endpoint address="" behaviorConfiguration="webHttp" binding="webHttpBinding"
name="webHttpBinding" contract="IRestService" />
</service>
</services>
</system.serviceModel>
有效负载是有效的 XML。
【问题讨论】: