[英]Why is my WCF wshttpbinding client doesn't work at another computer?
首先,我在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時,以及當我在Internet上尋找一些解決方案時,大多數人建議使用basicHttpBinding,但這不是我想要的答案,出於安全原因,我想使用wsHttpBinding
幫幫我,我被困了將近3天,仍然想不通
將安全模式設置為無。 您可以在WCF服務配置文件中創建綁定配置元素
<wsHttpBinding>
<binding name="XServerSvcBasicHttpEndPoint">
<security mode="None"></security>
</binding>
</wsHttpBinding>
並使用端點標記中的配置,例如
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="XServerSvcBasicHttpEndPoint"
name="XServerSvcBasicHttpEndPoint" contract="ServerTier.IServiceClient" />
在客戶端部分,將身份更改為以下格式身份impersonate =“ true” userName =“ domain \\ user” password =“ password” />
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.