Bre*_*ter 10 .net wcf web-services endpoints
我想要做的是让一个单一的WCF服务在HTTP方案的开发环境中工作,并且在生产环境中使用SAME服务也是HTTPS方案.如果我删除两个Https端点(后缀为'Https'),它可以在开发环境中工作; 同样,如果我只删除两个Http端点,那么它在生产环境中工作.如果可能的话,我想在web.config中拥有所有四个端点.
我的终点定义如下:
<endpoint address="/Web"
behaviorConfiguration="AjaxBehavior"
binding="wsHttpBinding"
bindingConfiguration="web"
name="Web"
contract="Service" />
<endpoint address="/Custom"
binding="customBinding"
bindingConfiguration="custom"
name="Custom"
contract="Service" />
<endpoint
address="/WebHttps"
behaviorConfiguration="AjaxBehavior"
binding="wsHttpBinding"
bindingConfiguration="webHttps"
name="WebHttps"
contract="Service" />
<endpoint address="/CustomHttps"
binding="customBinding"
bindingConfiguration="customHttps"
name="CustomHttps"
contract="Service" />
Run Code Online (Sandbox Code Playgroud)
编辑:我正在编辑我的问题,以添加我得到的错误,以及绑定部分(下面).对不起这个问题的新篇幅.
错误是:"无法找到与绑定WebHttpBinding的端点的方案http匹配的基址.已注册的基址方案为[https]."
此外,生产站点设置为"需要SSL".那无法改变.
绑定配置是:
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="AjaxBehavior">
<enableWebScript/>
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<customBinding>
<binding name="custom">
<textMessageEncoding>
<readerQuotas maxDepth="7000000" maxStringContentLength="7000000"
maxArrayLength="7000000" maxBytesPerRead="7000000"
maxNameTableCharCount="7000000" />
</textMessageEncoding>
<httpTransport maxBufferPoolSize="7000000" maxReceivedMessageSize="7000000"
maxBufferSize="7000000" />
</binding>
<binding name="customHttps">
<textMessageEncoding>
<readerQuotas maxDepth="7000000" maxStringContentLength="7000000"
maxArrayLength="7000000" maxBytesPerRead="7000000"
maxNameTableCharCount="7000000" />
</textMessageEncoding>
<httpsTransport maxBufferPoolSize="7000000" maxReceivedMessageSize="7000000"
maxBufferSize="7000000" />
</binding>
</customBinding>
<webHttpBinding>
<binding name="web" maxBufferPoolSize="70000000"
maxReceivedMessageSize="70000000">
<readerQuotas maxDepth="70000000" maxStringContentLength="70000000"
maxArrayLength="70000000" maxBytesPerRead="70000000"
maxNameTableCharCount="70000000" />
<security mode="None" />
</binding>
<binding name="webHttps" maxBufferPoolSize="70000000"
maxReceivedMessageSize="70000000">
<readerQuotas maxDepth="70000000" maxStringContentLength="70000000"
maxArrayLength="70000000" maxBytesPerRead="70000000"
maxNameTableCharCount="70000000" />
<security mode="Transport" />
</binding>
</webHttpBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
Vin*_*B R 25
跟着这些步骤-
1)为服务写两个端点,一个用于http,另一个用于https.
<services>
<service behaviorConfiguration="MyServiceBehavior" name="JK.MyService">
<endpoint address="" behaviorConfiguration="WebBehavior" binding="webHttpBinding" bindingConfiguration="webBinding" contract="JK.IMyService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="" behaviorConfiguration="WebBehavior" binding="webHttpBinding" bindingConfiguration="webBindingHTTPS" contract="JK.IMyService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</service>
</services>
Run Code Online (Sandbox Code Playgroud)
2)在serviceBehaviors中启用httpGetEnabled ="True"httpsGetEnabled ="true".
<behaviors>
<serviceBehaviors>
<behavior name="MyServiceBehavior">
<serviceMetadata httpGetEnabled="True" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="WebBehavior">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
Run Code Online (Sandbox Code Playgroud)
3)为http和https编写两个绑定配置.对于http,安全模式="无",对于https,给出模式="运输".
<bindings>
<webHttpBinding>
<binding name="webBinding">
<security mode="None">
<transport clientCredentialType="None" />
</security>
</binding>
<binding name="webBindingHTTPS">
<security mode="Transport">
<transport clientCredentialType="None" />
</security>
</binding>
</webHttpBinding>
</bindings>
Run Code Online (Sandbox Code Playgroud)
检查此链接