【问题标题】:How can I enable both http and https endpoint?如何同时启用 http 和 https 端点?
【发布时间】:2014-02-18 12:46:48
【问题描述】:

我正在访问在 WAS 服务器中设置的服务

允许 http 和 https 端点访问。如何在我的 app.config 文件中修改相同的内容?

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>    
<add key="WebServiceUrl1" value="http://vissvc-  test.e.corpintra.net/VisSvcNative/VisService"/>
<add key="LogoutUrl" value="http://login.e.corpintra.net/internal/logout"/>
</appSettings>
<system.net>
<defaultProxy >
  <proxy autoDetect ="True" />
</defaultProxy>
</system.net> 
<system.serviceModel>
<bindings>      
  <customBinding>
    <binding name="SoapBinding">  
      <customTextMessageEncoding encoding="UTF-8" messageVersion="Soap11" />  
      <httpTransport/>          
    </binding>       
  </customBinding>      
</bindings>        
<client>
  <endpoint address="http://vissvc-test.e.corpintra.net/VisSvcNative/VisService"
            binding="customBinding" bindingConfiguration="SoapBinding"                contract="ServiceReference1.VisServicePortType" name="VisService" behaviorConfiguration="behavior" />      
               </client>
 </system.serviceModel>
 </configuration>

我正在使用 .net c# 4.0

【问题讨论】:

标签: c# wcf app-config


【解决方案1】:

您可能还需要在&lt;httpTransport&gt; 下添加&lt;httpsTransport&gt;

查看MSDN,了解有关&lt;httpsTransport&gt; 标签的更多信息。

编辑:我的意思是&lt;httpsTransport&gt; 应该有另一个绑定配置,例如:

<bindings>      
  <customBinding>
     <binding name="SoapBinding">
        <httpTransport />
     </binding>
     <binding name="HttpsSoapBinding">
        <httpsTransport />
     </binding>     
  </customBinding>      
</bindings>  

另请注意,这些绑定名称必须与服务器配置上的名称匹配。

【讨论】:

  • 表示绑定名称已经存在。
  • 您必须在 httpsTransport 的第二个绑定配置中使用不同的名称。您对两者都使用了“Soapbinding”这个名称。
  • @HOKBONG- 好的,但这应该由服务预定义吗?
猜你喜欢
  • 2011-02-04
  • 2022-07-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-06-08
  • 2015-01-01
  • 2014-10-17
  • 1970-01-01
相关资源
最近更新 更多