SSL的WCF服务问题

时间:2010-02-25 15:57:02

标签: wcf

我从控制台应用程序通过SSL调用WCf服务时遇到问题。 WCF服务在Windows Server 2003上。它是简单的数学服务。 WCF服务和客户端位于同一台计算机上。这是测试,我在localhost上调用服务。

web.confing

<?xml version="1.0"?>
<configuration>
    <system.serviceModel>
        <services>
            <service name="Service.CalculatorService" behaviorConfiguration="CalculatorServiceBehavior">
                <endpoint address="https://machineName/https/calculatorservice.svc" name="myEndpoint" binding="basicHttpBinding" 
                  bindingConfiguration="Binding1" contract="Service.ICalculator"/>
            </service>
        </services>
        <bindings>
            <basicHttpBinding>
                <binding name="Binding1">
                    <security mode="Transport">
                        <transport clientCredentialType="None"/>
                    </security>
                </binding>
            </basicHttpBinding>
        </bindings>
        <behaviors>
   <serviceBehaviors>
    <behavior name="CalculatorServiceBehavior">
      <serviceMetadata httpsGetEnabled="true"
        httpsGetUrl="https://machineName/https/calculatorservice.svc" />
     <serviceDebug includeExceptionDetailInFaults="false" />
    </behavior>
   </serviceBehaviors>
  </behaviors>
    </system.serviceModel>
    <system.web>
        <compilation debug="true"/></system.web></configuration>

如果我从Visual Studio examaple调用服务:http://localhost:2039/CalculatorService.svc 我收到错误: 不支持协议“https”。我认为没问题。

但如果我从浏览器调用服务,我会收到错误:

URI'https://machineName/https/CalculatorService.svc'已经存在注册。

什么是坏事?任何人都可以帮助我,谢谢你。

2 个答案:

答案 0 :(得分:1)

从端点元素中删除“address”属性 - 当您在IIS中托管时,它会自动提供此属性。

答案 1 :(得分:0)

Visual Studio Development Server不支持https。您需要在IIS中托管您的服务 http://msdn.microsoft.com/en-us/library/vstudio/aa751792(v=vs.100).aspx