0
服務合同信息低於 服務合同:WCF Rest服務未返回JSON數據。但是,它適用於XML
[OperationContract]
[FaultContract(typeof(DcCustomFaultMessage))]
[WebInvoke(Method="GET", ResponseFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Wrapped,
UriTemplate = "/GetCustomData")]
List<DcCustomData> GetCustomData();
這裏的配置細節 配置:
<system.serviceModel>
<services>
<service name="MyService" behaviorConfiguration="MyServiceBehavior">
<endpoint address="" binding="webHttpBinding" bindingConfiguration="MyServiceBinding" behaviorConfiguration="web" contract="IMyService"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MyServiceBehavior">
<serviceDebug includeExceptionDetailInFaults="True"/>
<serviceTimeouts transactionTimeout="05:00:00"/>
<dataContractSerializer maxItemsInObjectGraph="2147483646"/>
<serviceMetadata httpGetEnabled="True"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="web" >
<webHttp helpEnabled="true" automaticFormatSelectionEnabled="false" defaultOutgoingResponseFormat="Json" />
</behavior>
</endpointBehaviors>
</behaviors>
<standardEndpoints>
<webHttpEndpoint>
<standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="false" defaultOutgoingResponseFormat="Json"/>
</webHttpEndpoint>
</standardEndpoints>
<bindings>
<webHttpBinding>
<binding name="MyServiceBinding">
<security mode="None"/>
</binding>
</webHttpBinding>
</bindings>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<diagnostics performanceCounters="All"/>
當我調試,GetCustomData()返回列表。但是當我檢查瀏覽器返回沒有..沒有錯誤信息。請幫我
如果我改變ResponseFormat = WebMessageFormat.Xml ,它適用於Xml \ – Raj