I am trying to call a SOAP webservice, however I am getting the error: Additional information: The username is not provided. Specify username in ClientCredentials.
So I thought I could just set client.ClientCredentials to a new instance of NetworkCredentials. However ClientCredentials is read only. So how can I go about passing this information on to access the web service?
myService.ServiceClient client = new myService.ServiceClient();
// This won't work since its read only.
client.ClientCredentials = new System.Net.NetworkCredential("username", "password", "domain");
string version = client.getData();
EDIT: Binding:
<binding name="VersionHttpBinding">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Basic" />
</security>
</binding>
You'll need to set the credentials on the client, like as shown in this MSDN article :
client.ClientCredentials.UserName.UserName = "my_user_name";
client.ClientCredentials.UserName.Password = "my_password";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.