如何启用http和https端点?

时间:2014-02-18 03:06:02

标签: c# wcf app-config

我正在访问已在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

1 个答案:

答案 0 :(得分:0)

您可能还需要在<httpsTransport>下添加<httpTransport>

有关<httpsTransport>标记的详细信息,请查看MSDN

编辑:我的意思是<httpsTransport>应该有另一个绑定配置,例如:

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

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