[英]How to connect to a WCF service with wsHttpBinding
I have hosted a WCF service wsHttpBinding. 我已经托管了WCF服务wsHttpBinding。 Then i have created a windows form application to access WCF services as a client application.
然后,我创建了一个Windows窗体应用程序,以作为客户端应用程序访问WCF服务。 Client application can invoke WCF services in local machine since credentials are defined as follows by defualt.
客户端应用程序可以在本地计算机中调用WCF服务,因为凭据由defualt定义如下。
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" />
but when i try to run same application on different PC on same network, there will be an authentication fail since its use WINDOWS credential type. 但是,当我尝试在同一网络上的不同PC上运行同一应用程序时,由于使用WINDOWS凭据类型,因此将导致身份验证失败。 So how can i authenticate other client PCs with wsHttpBinding over netowrk or internet?
那么,如何通过netowrk或Internet使用wsHttpBinding对其他客户端PC进行身份验证? Do i have to use a Certificate or Custom security token and how?
我必须使用证书或自定义安全令牌,如何使用?
This is my web.config of WCF service 这是我的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>
You need to add a service endpoint identity into your service configuration: 您需要在服务配置中添加服务端点标识:
<endpoint address="" binding="wsHttpBinding" contract="MyWCFService.ICenService">
<identity>
<dns value="(server name)" />
</identity>
</endpoint>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.