【问题标题】:How to connect to a WCF service with wsHttpBinding如何使用 wsHttpBinding 连接到 WCF 服务
【发布时间】:2012-08-31 23:21:47
【问题描述】:

我已经托管了一个 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>

【问题讨论】:

  • 您需要使用证书。
  • 好吧,我是 WCF 新手 如何使用证书?有教程吗?
  • 在同一个网络上应该不需要证书。

标签: wcf wshttpbinding wcf-wshttpbinding


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-04-03
    • 1970-01-01
    • 2018-10-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多