我有一個WCF文件服務器和客戶端在Localhost中工作完美,但是當我將服務器安裝到另一臺計算機時,當客戶端要上傳文件時,客戶端會引發異常。例外是:WCF文件服務器中的端點
服務器拒絕憑據。
我在客戶端的配置文件中添加一個新的服務器IP(172.18.20.25)。
這是我的客戶端配置文件:
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<client>
<endpoint name="FileRepositoryService"
address="net.tcp://172.18.20.25:5000" binding="netTcpBinding"
contract="FileServer.Services.IFileRepositoryService"
bindingConfiguration="customTcpBinding"/>
</client>
<bindings>
<netTcpBinding>
<binding name="customTcpBinding"
maxReceivedMessageSize="2147483648" transferMode="Streamed"/>
</netTcpBinding>
</bindings>
</system.serviceModel>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
</configuration>
這是我的服務器的配置:
<?xml version="1.0"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
<appSettings>
<add key="RepositoryDirectory" value="storage"/>
</appSettings>
<system.serviceModel>
<services>
<service name="FileServer.Services.FileRepositoryService">
<endpoint name="" binding="netTcpBinding"
address="net.tcp://localhost:5000"
contract="FileServer.Services.IFileRepositoryService"
bindingConfiguration="customTcpBinding" />
</service>
</services>
<bindings>
<netTcpBinding>
<binding name="customTcpBinding" transferMode="Streamed"
maxReceivedMessageSize="2147483648" />
</netTcpBinding>
</bindings>
</system.serviceModel>
</configuration>
當客戶端和服務器在一臺機器上運行之前提到的它工作得很好。我讀過關於添加一個新的WSDL端點到服務器,我不知道它,我不知道如何添加它。你有什麼建議?
您使用基本'netTcpBinding'默認爲使用Windows用戶帳戶的安全性。因此,如果您的「新」客戶端和「新」服務器不屬於同一個Windows域,或者客戶端的PC在不屬於該Windows域的帳戶下運行,則它將不起作用。 – 2012-02-09 08:17:12
閱讀[編程WCF安全](http://msdn.microsoft.com/en-us/library/ms731925.aspx),看看哪個設置最適合您的服務 – 2012-02-09 08:17:56