更新时间:2022-12-14 23:07:29
像Sandrino提到的,我不需要基本验证得到的授权和认证使用自定义的用户名和密码。
Like Sandrino mentioned, I don't need basicauth to get authorization and authentication with a custom username and password.
而不是:
<security mode="Transport">
<transport clientCredentialType="Basic"/>
</security>
我不得不这样做:
I had to do:
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="None"/>
<message clientCredentialType="UserName" />
</security>
在客户端:
ServiceReference1.CvServiceInterfaceClient cl = new ServiceReference1.CvServiceInterfaceClient();
ClientCredentials creds = new ClientCredentials();
creds.UserName.UserName = "username";
creds.UserName.Password = "password";
var defaultCredentials = cl.Endpoint.Behaviors.Find<ClientCredentials>();
cl.Endpoint.Behaviors.Remove(defaultCredentials);
cl.Endpoint.Behaviors.Add(creds);
吉荣