使用SOAP和JSON端点迁移到WCF服务 - JSON响应不符合预期

时间:2014-02-27 09:39:41

标签: json wcf soap

我将Web服务迁移到WCF服务。该服务公开两个端点,一个返回JSON,另一个返回SOAP。

SOAP端点按预期工作,但来自JSON端点的响应用响应对象名称包装 - 在我用于返回的Web服务的JSON响应中不存在。

我尝试使用BodyStyle属性,但我得到的只是一个例外:The body style 'Bare' is not supported by 'WebScriptEnablingBehavior'. Change the body style to be 'WrappedRequest'

我的所有方法只接受POST请求。

这是我的服务配置方式:

<services>
    <service name="MyService" behaviorConfiguration="MyServiceBehavior">
        <endpoint address="" binding="basicHttpBinding" bindingNamespace="http://MyService.org/" contract="IMyService"/>
        <endpoint address="json" behaviorConfiguration="JsonEndpointBehavior" binding="webHttpBinding" contract="IMyService" />
    </service>
</services>
<behaviors>
    <endpointBehaviors>
        <behavior name="JsonEndpointBehavior">
            <enableWebScript />
        </behavior>
    </endpointBehaviors>
    <serviceBehaviors>
        <behavior name="MyServiceBehavior">
            <serviceMetadata httpGetEnabled="true" />
            <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
    </serviceBehaviors>
</behaviors>

0 个答案:

没有答案