1

我想将我使用的 Web 服务的 UserCredentials 添加到我网站的 web.config 文件中。

例如:

<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>

用户名="123" 密码="123"

代替

ws.SomethingServiceClient svc = new ws.SomethingServiceClient();
svc.ClientCredentials.UserName.UserName = 123;
svc.ClientCredentials.UserName.Password = 123;
4

0 回答 0