我們有一個在HTTPS上正常工作但在HTTPS上顯示HTTP 415錯誤的web服務。所以,在HTTP下,我們可以發出一個POST請求發送和接收JSON而沒有問題。當我們在HTTPS下嘗試使用相同的服務時,我們得到的錯誤是服務期望application/json的text/xml insteas。任何建議在哪裏看?HTTP 415由於內容類型'application/json; charset = utf-8'不是預期的類型'text/xml; charset = utf-8'
服務器使用簽名的證書,如果該事項自我。
綁定的更新和行爲
<!-- Wcf Services Setting -->
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WsHttpBinding" maxReceivedMessageSize="1048576">
<readerQuotas maxArrayLength="1048576" />
</binding>
<binding name="SecureWsHttpBinding" maxReceivedMessageSize="1048576">
<readerQuotas maxArrayLength="1048576" />
<security mode="Transport">
<transport clientCredentialType="None" />
</security>
</binding>
</wsHttpBinding>
<webHttpBinding>
<binding name="WebHttpBinding" maxReceivedMessageSize="1048576">
<readerQuotas maxArrayLength="1048576" />
</binding>
<binding name="SecureWebHttpBinding" maxReceivedMessageSize="1048576">
<readerQuotas maxArrayLength="1048576" />
<security mode="Transport">
<transport clientCredentialType="None" />
</security>
</binding>
<binding name="webBinding">
<security mode="Transport">
</security>
</binding>
</webHttpBinding>
<basicHttpBinding>
<binding name="BasicHttpBinding_IMainService" maxReceivedMessageSize="1048576"></binding>
<binding name="BasicHttpBinding" maxReceivedMessageSize="1048576">
<readerQuotas maxArrayLength="1048576" />
<security mode="None">
<transport clientCredentialType="None" />
</security>
</binding>
<binding name="SecureBasicHttpBinding" maxReceivedMessageSize="1048576">
<readerQuotas maxArrayLength="1048576" />
<security mode="Transport">
<transport clientCredentialType="None" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="AjaxBehavior">
<webHttp DefaultOutgoingResponseFormat="json" />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="DvaMfs.WcfService">
<useRequestHeadersForMetadataAddress>
<defaultPorts>
<add scheme="https" port="443" />
</defaultPorts>
</useRequestHeadersForMetadataAddress>
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
服務這個樣子
<service name="DvaMfs.WcfService.ProductService" behaviorConfiguration="DvaMfs.WcfService">
<endpoint name="ProductServiceEndPoint" address="" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding" contract="DvaMfs.WcfService.IProductService" />
<endpoint name="ProductServiceAjaxEndPoint" address="ajax" binding="webHttpBinding" bindingConfiguration="WebHttpBinding" behaviorConfiguration="AjaxBehavior" contract="DvaMfs.WcfService.IProductService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<endpoint name="ProductServiceSecureEndPoint" address="ProductServiceSecure" binding="basicHttpBinding" bindingConfiguration="SecureBasicHttpBinding" contract="DvaMfs.WcfService.IProductService" />
<endpoint name="ProductServiceAjaxSecureEndPoint" address="ProductServiceSecureajax" binding="webHttpBinding" bindingConfiguration="SecureWebHttpBinding" behaviorConfiguration="AjaxBehavior" contract="DvaMfs.WcfService.IProductService" />
</service>
更新2 這是端點失敗的一個:
<endpoint name="DataServiceSecureEndPoint" address="" binding="basicHttpBinding"
bindingConfiguration="SecureBasicHttpBinding" contract="DvaMfs.WcfService.IDataService" />
假設,請提供bindingConfiguration和行爲。這是你錯誤的關鍵,我認爲 – Caveman 2014-10-29 08:04:01
順便說一句,我嘗試了所有與SO相同的錯誤沒有任何運氣的問題的所有建議。 – momo 2014-10-29 08:33:50
@CapitanCavernícola用配置文件的一部分更新了問題。 – momo 2014-10-29 08:35:25