[英]Why am I getting a “401 - Unauthorized” error when sending a file byte stream to a WCF service?
[英]Why am I getting this error when trying to connect to my WCF service
The caller was not authenticated by the service.
作为客户端连接到第一台计算机上的WCF服务,我在一台计算机上的Windows服务中托管了WCF服务,而另一台计算机上又存在另一台Windows服务。 我猜想它与安全性有关,但是我不确定该怎么做。 这是客户端的app.config:
<system.serviceModel>
<bindings>
<wsDualHttpBinding>
<binding name="WSDualHttpBinding_IWCFService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
<reliableSession ordered="true" inactivityTimeout="00:10:00"/>
<security mode="Message">
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default"/>
</security>
</binding>
</wsDualHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:8731/Design_Time_Addresses/WCF/WCFService/"
binding="wsDualHttpBinding" bindingConfiguration="WSDualHttpBinding_IWCFService"
contract="WCFService.IWCFService" name="WSDualHttpBinding_IWCFService">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
</client>
</system.serviceModel>
以及该服务的app.config:
<system.serviceModel>
<services>
<service name="WCF.WCFService" behaviorConfiguration="WCFBehavior">
<endpoint address="" binding="wsDualHttpBinding" contract="WCF.IWCFService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint
address="mex"
binding="mexHttpBinding"
bindingConfiguration=""
contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8731/Design_Time_Addresses/WCF/WCFService/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="WCFBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
我需要做些什么才能能够连接到WCF服务。
要注意的另一件事是,我创建了一个简单的控制台应用程序作为wcf服务的客户端,它可以毫无问题地连接到该服务,并且app.config文件看起来相同。 也许与以其他用户身份运行的客户端服务有关? 我可以删除所有安全性,但不知道如何。
控制台应用程序可能正在使用您的凭据运行,无法与wcf服务连接的Windows服务可能正在使用本地系统帐户运行。 尝试使用身份验证模式“用户”和您的凭据安装服务
两件事:检查上面的身份,并确保您的其他服务不是以本地用户身份运行(默认!例如NetworkService),而是以域用户身份运行或重新考虑您的设置(您可以通过在您的帐户下运行该服务来进行测试)如果您在域中拥有所需的权利)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.