我想将我使用的Web服务的UserCredentials添加到我网站的web.config文件中。
e.g:
<system.serviceModel>
<bindings>
<customBinding>
<binding bindingConfiguration="myBinding"
<security enableUnsecuredResponse="true" authenticationMode="UserNameOverTransport" securityHeaderLayout="Lax" />
<textMessageEncoding messageVersion="Soap11" />
<httpsTransport />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="https://www.mycompany.com/foo.ashx" binding="customBinding" bindingConfiguration="myBinding" username="123" password="123" contract="foo.bar" name="foosoap" />
</client>
</system.serviceModel>
username =“123”password =“123”
而不是
ws.SomethingServiceClient svc = new ws.SomethingServiceClient();
svc.ClientCredentials.UserName.UserName = 123;
svc.ClientCredentials.UserName.Password = 123;