1

我已经托管了一个 WCF 服务 wsHttpBinding。然后我创建了一个 Windows 窗体应用程序来作为客户端应用程序访问 WCF 服务。客户端应用程序可以在本地机器中调用 WCF 服务,因为凭据由默认定义如下。

<transport clientCredentialType="Windows" proxyCredentialType="None"
                    realm="" />
                <message clientCredentialType="Windows" negotiateServiceCredential="true"
                    algorithmSuite="Default" />

但是当我尝试在同一网络上的不同 PC 上运行相同的应用程序时,会出现身份验证失败,因为它使用 WINDOWS 凭据类型。那么如何通过网络或互联网使用 wsHttpBinding 对其他客户端 PC 进行身份验证?我是否必须使用证书或自定义安全令牌以及如何使用?

这是我的 WCF 服务的 web.config

    <configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="true"/>
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <services>
      <service name="MyWCFService.CenService">
        <endpoint address="" binding="wsHttpBinding" contract="MyWCFService.ICenService"/>
      </service>
      <!--<service name="CenService.MyService">
        <endpoint address="" binding="wsHttpBinding" contract="MyWCFService.IMyService"/>
      </service>-->
     </services>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>

</configuration>
4

1 回答 1

1

您需要将服务端点身份添加到服务配置中:

<endpoint address="" binding="wsHttpBinding" contract="MyWCFService.ICenService">
    <identity>
        <dns value="(server name)" />
    </identity>
</endpoint>
于 2012-09-07T09:13:19.573 回答