如何使用wsHttpBinding连接到WCF服务

时间:2012-09-07 04:56:10

标签: wcf wshttpbinding wcf-wshttpbinding

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

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

但是当我尝试在同一网络上的不同PC上运行相同的应用程序时,由于其使用WINDOWS凭据类型,将会出现身份验证失败。 那么如何使用wsHttpBinding over netowrk或internet来验证其他客户端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>

1 个答案:

答案 0 :(得分:1)

您需要在服务配置中添加服务端点标识:

<endpoint address="" binding="wsHttpBinding" contract="MyWCFService.ICenService">
    <identity>
        <dns value="(server name)" />
    </identity>
</endpoint>