[英]How to connect to a WCF service with wsHttpBinding
我已经托管了WCF服务wsHttpBinding。 然后,我创建了一个Windows窗体应用程序,以作为客户端应用程序访问WCF服务。 客户端应用程序可以在本地计算机中调用WCF服务,因为凭据由defualt定义如下。
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" />
但是,当我尝试在同一网络上的不同PC上运行同一应用程序时,由于使用WINDOWS凭据类型,因此将导致身份验证失败。 那么,如何通过netowrk或Internet使用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>
您需要在服务配置中添加服务端点标识:
<endpoint address="" binding="wsHttpBinding" contract="MyWCFService.ICenService">
<identity>
<dns value="(server name)" />
</identity>
</endpoint>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.