如何为具有HTTPS端点的WCF服务生成客户端代理?

时间:2009-04-02 12:51:03

标签: wcf security authentication https

可能与此前一个问题相同:WCF Proxy但不确定...

我有一个HTTPS服务配置为使用传输安全性,我希望,Windows凭据。该服务仅在内部访问(即在Intranet内)。配置如下:

<configuration>
  <system.serviceModel>
    <services>
      <service name="WCFTest.CalculatorService" behaviorConfiguration="WCFTest.CalculatorBehavior">
        <host>
          <baseAddresses>
            <add baseAddress = "https://localhost:8000/WCFTest/CalculatorService/" />
          </baseAddresses>
        </host>
        <endpoint address ="basicHttpEP" binding="basicHttpBinding" contract="WCFTest.ICalculatorService" bindingConfiguration="basicHttpBindingConfig"/>    
        <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
      </service>
    </services>
    <bindings>
      <basicHttpBinding>
        <binding name="basicHttpBindingConfig">
          <security mode="Transport">
            <transport clientCredentialType = "Windows"/>
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="WCFTest.CalculatorBehavior">          
          <serviceAuthorization impersonateCallerForAllOperations="false"  principalPermissionMode="UseWindowsGroups" />
          <serviceCredentials >
            <windowsAuthentication allowAnonymousLogons="false" includeWindowsGroups="true" />
          </serviceCredentials>
          <serviceMetadata httpsGetEnabled="True"/>
          <serviceDebug includeExceptionDetailInFaults="False" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

当我运行该服务时,我无法在IE中看到该服务。我收到“此页面无法显示”错误。如果我尝试通过“添加服务引用”向导在VS2008中创建一个客户端,我会收到此错误:

  

下载时出错   'https://localhost:8000/WCFTest/CalculatorService/'。   下载时出错   'https://localhost:8000/WCFTest/CalculatorService/'。   底层连接已关闭:   a上发生意外错误   发送。验证失败,因为   远程队已经关闭了   运输流。元数据包含一个   无法解决的参考:   'https://localhost:8000/WCFTest/CalculatorService/'。   制作时发生错误   HTTP请求   https://localhost:8000/WCFTest/CalculatorService/。   这可能是因为这个事实   未配置服务器证书   适当地使用HTTPS中的HTTP.SYS   案件。这也可能是由a引起的   安全绑定不匹配   客户端和服务器之间。该   基础连接已关闭:An   发送时发生意外错误。   身份验证失败,因为   远程党已关闭运输   流。如果定义了服务   目前的解决方案,尝试建立   解决方案并添加服务   再次参考。

我想我在这里缺少一些基本的基础知识。我需要设置一些证书吗?或者它应该只是像我使用NetTcpBinding时那样工作吗?

由于

3 个答案:

答案 0 :(得分:0)

ng5000,

好像你可能在这里有另一个问题(也许是IIS)。您是否在运输级别安全方面遇到任何问题?在检查WCF之前,我还要确保你可以访问IE中的网址。听起来像安全选项卡中的IIS设置不正确。

如果仍然存在问题,请尝试关闭传输级安全性的代理,然后返回并将这两个配置更改为传输级别窗口安全性,看看会发生什么。

布莱恩

答案 1 :(得分:0)

...
<security defaultAlgorithmSuite="Default" authenticationMode="IssuedTokenOverTransport"
                    requireDerivedKeys="false" securityHeaderLayout="Strict" includeTimestamp="true"
                    keyEntropyMode="CombinedEntropy" messageSecurityVersion="WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10">
                    <issuedTokenParameters keyType="SymmetricKey" tokenType="" />
...

这是我的解决方法。我得到了上面的配置文件,并将authenticationMode从“IssuedTokenOverTransport”更改为“UserNameOverTransport”。它解决了我的环境问题。

答案 2 :(得分:-1)

更改

<endpoint address ="basicHttpEP" binding="basicHttpBinding" contract="WCFTest.ICalculatorService" bindingConfiguration="basicHttpBindingConfig"/>

<endpoint address ="basicHttpEP" binding="basicHttpsBinding" contract="WCFTest.ICalculatorService" bindingConfiguration="basicHttpBindingConfig"/>
相关问题