首先,我在winform中托管我的wcf服务,并尝试使用wsHttpBinding。我的客户端应用程序仅在我的开发计算机中工为什么我的WCF wshttpbinding客户端无法在另一台计算机上运行?在另一台计算机中,当我执行服务时,它显示“调用者未被服务认证”
这是我的WCF winform主机配置(app.config):
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<connectionStrings>
<add name="DBCS"
connectionString="data source=localhost;DataBase=LatihanSP;Integrated Security=SSPI"
providerName="System.Data.SqlClient" />
</connectionStrings>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="XServerSvcBehavior">
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="XServerSvcBehavior" name="ServerTier.ServiceClient">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration=""
name="XServerSvcBasicHttpEndPoint" contract="ServerTier.IServiceClient" />
<endpoint address="mex" binding="mexHttpBinding" bindingConfiguration=""
name="XServerSvcMexHttpEndPoint" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:7777/SampleSvc" />
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
</configuration>
这是我的客户端app.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="XServerSvcBasicHttpEndPoint" />
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:7777/SampleSvc" binding="wsHttpBinding"
bindingConfiguration="XServerSvcBasicHttpEndPoint" contract="ServiceRef.IServiceClient"
name="XServerSvcBasicHttpEndPoint">
<identity>
<userPrincipalName value="Kevin-EDP\Kevin" />
</identity>
</endpoint>
</client>
</system.serviceModel>
</configuration>
我尝试将userPrincipalName值更改为计算机的名称,仍然我的客户端将无法正常工作,当我执行该服务时,它显示“调用者未被服务验证” 我确实我的代码工作正常,当我使用basicHttpBinding时,当我在互联网上看一些解决方案时,大多数人建议使用basicHttpBinding,但这不是我想要的答案,我想使用wsHttpBinding以保证安全性
帮助我的家伙,我被困了将近3天,仍然无法弄清楚
答案 0 :(得分:1)
将安全模式设置为none。您可以在WCF服务配置文件
中创建绑定配置元素<wsHttpBinding>
<binding name="XServerSvcBasicHttpEndPoint">
<security mode="None"></security>
</binding>
</wsHttpBinding>
并使用端点标记中的配置,如
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="XServerSvcBasicHttpEndPoint"
name="XServerSvcBasicHttpEndPoint" contract="ServerTier.IServiceClient" />
答案 1 :(得分:0)
在客户端部分将身份更改为以下格式 identity impersonate =“true”userName =“domain \ user”password =“password”/&gt;