I am trying to access my WCF service on a server from my client console application for testing. I am getting the following error:
我试图从我的客户端控制台应用程序访问服务器上的WCF服务进行测试。我收到以下错误:
The caller was not authenticated by the service
呼叫者未通过该服务进行身份验证
I am using wsHttpBinding
. I'm not sure what kind of authentication the service is expecting?
我正在使用wsHttpBinding。我不确定服务期望的验证类型是什么?
<behaviors>
<serviceBehaviors>
<behavior name="MyTrakerService.MyTrakerServiceBehavior">
<!-- 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>
Update It works if I change my binding to <endpoint "basicHttpBinding" ... />
(from wsHttpBinding) on the IIS 7.0 hosted, windows 2008 server
更新如果我在IIS 7.0托管的Windows 2008服务器上将绑定更改为
10 个解决方案
#1
25
If you use basicHttpBinding, configure the endpoint security to "None" and transport clientCredintialType to "None."
如果使用basicHttpBinding,请将端点安全性配置为“None”,并将clientCredintialType传输为“None”。
<bindings>
<basicHttpBinding>
<binding name="MyBasicHttpBinding">
<security mode="None">
<transport clientCredentialType="None" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="MyServiceBehavior" name="MyService">
<endpoint
binding="basicHttpBinding"
bindingConfiguration="MyBasicHttpBinding"
name="basicEndPoint"
contract="IMyService"
/>
</service>
Also, make sure the directory Authentication Methods in IIS to Enable Anonymous access
此外,请确保IIS中的目录身份验证方法启用匿名访问
#2
23
I got it.
我知道了。
If you want to use wshttpbinding, u need to add windows credentials as below.
如果要使用wshttpbinding,则需要添加Windows凭据,如下所示。
svc.ClientCredentials.Windows.ClientCredential.UserName = "abc";
svc.ClientCredentials.Windows.ClientCredential.Password = "xxx";
thanks
谢谢
#3
4
Have you tried using basicHttpBinding instead of wsHttpBinding? If do not need any authentication and the Ws-* implementations are not required, you'd probably be better off with plain old basicHttpBinding. WsHttpBinding implements WS-Security for message security and authentication.
您是否尝试过使用basicHttpBinding而不是wsHttpBinding?如果不需要任何身份验证并且不需要Ws- *实现,那么使用普通的basicHttpBinding可能会更好。 WsHttpBinding实现了WS-Security以实现消息安全性和身份验证。
#4
1
set anonymous access in your virtual directory
在虚拟目录中设置匿名访问
write following credentials to your service
将以下凭据写入您的服务
ADTService.ServiceClient adtService = new ADTService.ServiceClient();
adtService.ClientCredentials.Windows.ClientCredential.UserName="windowsuseraccountname";
adtService.ClientCredentials.Windows.ClientCredential.Password="windowsuseraccountpassword";
adtService.ClientCredentials.Windows.ClientCredential.Domain="windowspcname";
after that you call your webservice methods.
之后,您调用您的Web服务方法。
#5
1
If you're using a self hosted site like me, the way to avoid this problem (as described above) is to stipulate on both the host and client side that the wsHttpBinding security mode = NONE.
如果您使用像我这样的自托管站点,避免此问题的方法(如上所述)是在主机和客户端都规定wsHttpBinding安全模式= NONE。
When creating the binding, both on the client and the host, you can use this code:
在客户端和主机上创建绑定时,您可以使用以下代码:
Dim binding as System.ServiceModel.WSHttpBinding
binding= New System.ServiceModel.WSHttpBinding(System.ServiceModel.SecurityMode.None)
or
要么
System.ServiceModel.WSHttpBinding binding
binding = new System.ServiceModel.WSHttpBinding(System.ServiceModel.SecurityMode.None);
#6
1
We ran into a weird issue where the folder where the WCF service was being hosted from had some permissions that were causing the problem.
我们遇到了一个奇怪的问题,其中托管WCF服务的文件夹具有导致问题的一些权限。
#7
1
I was able to resolve the shared issue by following below steps:
我可以通过以下步骤解决共享问题:
- Go to IIS-->Sites-->Your Site-->
- 转到IIS - >站点 - >您的站点 - >
- Features View Pane-->Authentication
- 功能查看窗格 - >身份验证
- Set Anonymous Authentication to Disabled
- 将匿名身份验证设置为已禁用
- Set Windows Authentication to Enabled
- 将Windows身份验证设置为已启用
#8
0
if needed to specify domain(which authecticates username and password that client uses) in webconfig you can put this in system.serviceModel services service section:
如果需要在webconfig中指定域(验证客户端使用的用户名和密码),可以将其放入system.serviceModel服务服务部分:
<identity>
<servicePrincipalName value="example.com" />
</identity>
and in client specify domain and username and password:
并在客户端指定域名,用户名和密码:
client.ClientCredentials.Windows.ClientCredential.Domain = "example.com";
client.ClientCredentials.Windows.ClientCredential.UserName = "UserName ";
client.ClientCredentials.Windows.ClientCredential.Password = "Password";
#9
0
This can be caused if the client is in a different domain than the server.
如果客户端位于与服务器不同的域中,则可能导致此问题。
I encountered this when testing one of my applications from my PC(client) to my (cloud) testing server and the simplest solution i could think of was setting up a vpn.
我在从我的PC(客户端)到我的(云)测试服务器测试我的一个应用程序时遇到了这个问题,而我能想到的最简单的解决方案是设置一个vpn。
#10
-1
Why can't you just remove the security setting altogether for wsHttpBinding ("none" instead of "message" or "transport")?
为什么你不能完全删除wsHttpBinding的安全设置(“none”而不是“message”或“transport”)?
#1
25
If you use basicHttpBinding, configure the endpoint security to "None" and transport clientCredintialType to "None."
如果使用basicHttpBinding,请将端点安全性配置为“None”,并将clientCredintialType传输为“None”。
<bindings>
<basicHttpBinding>
<binding name="MyBasicHttpBinding">
<security mode="None">
<transport clientCredentialType="None" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="MyServiceBehavior" name="MyService">
<endpoint
binding="basicHttpBinding"
bindingConfiguration="MyBasicHttpBinding"
name="basicEndPoint"
contract="IMyService"
/>
</service>
Also, make sure the directory Authentication Methods in IIS to Enable Anonymous access
此外,请确保IIS中的目录身份验证方法启用匿名访问
#2
23
I got it.
我知道了。
If you want to use wshttpbinding, u need to add windows credentials as below.
如果要使用wshttpbinding,则需要添加Windows凭据,如下所示。
svc.ClientCredentials.Windows.ClientCredential.UserName = "abc";
svc.ClientCredentials.Windows.ClientCredential.Password = "xxx";
thanks
谢谢
#3
4
Have you tried using basicHttpBinding instead of wsHttpBinding? If do not need any authentication and the Ws-* implementations are not required, you'd probably be better off with plain old basicHttpBinding. WsHttpBinding implements WS-Security for message security and authentication.
您是否尝试过使用basicHttpBinding而不是wsHttpBinding?如果不需要任何身份验证并且不需要Ws- *实现,那么使用普通的basicHttpBinding可能会更好。 WsHttpBinding实现了WS-Security以实现消息安全性和身份验证。
#4
1
set anonymous access in your virtual directory
在虚拟目录中设置匿名访问
write following credentials to your service
将以下凭据写入您的服务
ADTService.ServiceClient adtService = new ADTService.ServiceClient();
adtService.ClientCredentials.Windows.ClientCredential.UserName="windowsuseraccountname";
adtService.ClientCredentials.Windows.ClientCredential.Password="windowsuseraccountpassword";
adtService.ClientCredentials.Windows.ClientCredential.Domain="windowspcname";
after that you call your webservice methods.
之后,您调用您的Web服务方法。
#5
1
If you're using a self hosted site like me, the way to avoid this problem (as described above) is to stipulate on both the host and client side that the wsHttpBinding security mode = NONE.
如果您使用像我这样的自托管站点,避免此问题的方法(如上所述)是在主机和客户端都规定wsHttpBinding安全模式= NONE。
When creating the binding, both on the client and the host, you can use this code:
在客户端和主机上创建绑定时,您可以使用以下代码:
Dim binding as System.ServiceModel.WSHttpBinding
binding= New System.ServiceModel.WSHttpBinding(System.ServiceModel.SecurityMode.None)
or
要么
System.ServiceModel.WSHttpBinding binding
binding = new System.ServiceModel.WSHttpBinding(System.ServiceModel.SecurityMode.None);
#6
1
We ran into a weird issue where the folder where the WCF service was being hosted from had some permissions that were causing the problem.
我们遇到了一个奇怪的问题,其中托管WCF服务的文件夹具有导致问题的一些权限。
#7
1
I was able to resolve the shared issue by following below steps:
我可以通过以下步骤解决共享问题:
- Go to IIS-->Sites-->Your Site-->
- 转到IIS - >站点 - >您的站点 - >
- Features View Pane-->Authentication
- 功能查看窗格 - >身份验证
- Set Anonymous Authentication to Disabled
- 将匿名身份验证设置为已禁用
- Set Windows Authentication to Enabled
- 将Windows身份验证设置为已启用
#8
0
if needed to specify domain(which authecticates username and password that client uses) in webconfig you can put this in system.serviceModel services service section:
如果需要在webconfig中指定域(验证客户端使用的用户名和密码),可以将其放入system.serviceModel服务服务部分:
<identity>
<servicePrincipalName value="example.com" />
</identity>
and in client specify domain and username and password:
并在客户端指定域名,用户名和密码:
client.ClientCredentials.Windows.ClientCredential.Domain = "example.com";
client.ClientCredentials.Windows.ClientCredential.UserName = "UserName ";
client.ClientCredentials.Windows.ClientCredential.Password = "Password";
#9
0
This can be caused if the client is in a different domain than the server.
如果客户端位于与服务器不同的域中,则可能导致此问题。
I encountered this when testing one of my applications from my PC(client) to my (cloud) testing server and the simplest solution i could think of was setting up a vpn.
我在从我的PC(客户端)到我的(云)测试服务器测试我的一个应用程序时遇到了这个问题,而我能想到的最简单的解决方案是设置一个vpn。
#10
-1
Why can't you just remove the security setting altogether for wsHttpBinding ("none" instead of "message" or "transport")?
为什么你不能完全删除wsHttpBinding的安全设置(“none”而不是“message”或“transport”)?