我有一个Web服务的WSDL,我产生了WCF代理。没问题。
I have a wsdl from a web service, I generated the wcf proxy. No problem.
但我不能让我的头,围绕如何通过用户名和密码。该Web服务需要基本身份验证 - 只有用户名和密码
But I can not get my head around how to pass the user name and password. The webservice requires basic authentication - only username and password.
任何帮助吗?
被配置为配置文件中的基本身份验证?你需要传递唯一凭据或做你也需要安全的交通工具(HTTPS)?
Is Basic authentication configured in configuration file? Do you need to pass only credentials or do you also need secured transport (HTTPS)?
首先,您需要设置绑定,支持基本身份验证
First you need to set up binding to support Basic authentication
设置为HTTP绑定:
<bindings>
<basicHttpBinding>
<binding name="BasicAuth">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Basic" />
</security>
</binding>
</basicHttpBinding>
</bindings>
设置为HTTPS绑定:
Setup for HTTPS binding:
<bindings>
<basicHttpBidning>
<binding name="BasicAuthSecured">
<security mode="Transport">
<transport clientCredentialType="Basic" />
</security>
</binding>
</basicHttpBinding>
</bindings>
客户端的端点必须使用定义的配置,如:
Client endpoint has to use defined configuration like:
<client>
<endpoint address="..."
name="..."
binding="basicHttpBinding"
bindingConfiguration="BasicAuth"
contract="..." />
</client>
然后,你必须传递凭据到代理:
Then you have to pass credentials to the proxy:
proxy = new MyServiceClient();
proxy.ClientCredentials.UserName.UserName = "...";
proxy.ClientCredentials.UserName.Password = "...";
上一篇:从一个工作线程调用UI线程死锁时,死锁、线程、工作、UI
下一篇:我可以在Windows Server 2003上运行.NET 4.0的Web应用程序?应用程序、Server、Windows、Web