使用Https的WCF Json服务 [英] WCF Json Service with Https
本文介绍了使用Https的WCF Json服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请任何人帮助我。
Web服务器对Https的错误响应:
Works很好用Http:
Please any one Help me.
Error Response from Web Server for Https:
Works Fine with Http:
<Fault xmlns="http://schemas.microsoft.com/ws/2005/05/envelope/none">
- <Code>
<Value>Sender</Value>
- <Subcode>
<Value xmlns:a="http://schemas.microsoft.com/ws/2005/05/addressing/none">a:ActionNotSupported</Value>
</Subcode>
</Code>
- <Reason>
<Text xml:lang="en-US">The message with Action '' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).</Text>
</Reason>
</Fault>
网页配置:
Web Config:
<system.serviceModel>
<bindings>
<webHttpBinding>
<binding name="webBinding">
<security mode="Transport">
</security>
</binding>
</webHttpBinding>
</bindings>
<services>
<service name="MyService" behaviorConfiguration="BehConfig">
<endpoint contract="IMyService" address="" binding="webHttpBinding" bindingConfiguration="webBinding" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="BehConfig">
<serviceMetadata httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
</system.serviceModel>
推荐答案
<endpoint kind="webHttpEndpoint" binding="webHttpBinding" bindingConfiguration="wsBinding" contract="SS_Rest.ITestSOA" />
Https解决方案:
Solution For Https:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.web>
<compilation debug="true" strict="false" explicit="true" targetFramework="4.0" />
<httpRuntime maxUrlLength="500" />
</system.web>
<appSettings>
<add key="Constr" value="Data Source=YourConnection" />
</appSettings>
<system.serviceModel>
<services>
<service name="MyService">
<endpoint address="" binding="webHttpBinding" bindingConfiguration="secureHttpBinding" contract="IMyService" behaviorConfiguration="web" /> </service> </services> <bindings><webHttpBinding><binding name="secureHttpBinding" >
<security mode="Transport">
<transport clientCredentialType="None" />
</security>
</binding>
</webHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="web">
<webHttp/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --> <serviceMetadata httpsGetEnabled="true" httpGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="false" /> </behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer> <modules runAllManagedModulesForAllRequests="true" />
<httpRedirect enabled="false" />
</system.webServer>
</configuration>
对于Http:
For Http:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.web>
<compilation debug="true" strict="false" explicit="true" targetFramework="4.0" />
<httpRuntime />
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID" />
</system.web>
<appSettings>
<!--<add key="Constr" value="Data Source=;Initial Catalog=;User ID=;Password="/>-->
<add key="Constr" value="YourConnection" />
</appSettings>
<system.serviceModel>
<services>
<service name="MyService" behaviorConfiguration="BehConfig">
<endpoint address="" binding="webHttpBinding" contract="IMyService " behaviorConfiguration="web" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="BehConfig">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="web">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<!--
To browse web app root directory during debugging, set the value below to true.
Set to false before deployment to avoid disclosing web app folder information.
-->
<directoryBrowse enabled="true" />
<httpRedirect enabled="false" />
</system.webServer>
</configuration>
这篇关于使用Https的WCF Json服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文