Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass credentials to a SOAP webservice?

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> 
like image 565
John Doe Avatar asked May 09 '16 16:05

John Doe


People also ask

How do I send credentials in SOAP header?

UserName. Password = "testPass"; In this way you can pass username, password in the header to a SOAP WCF Service.

How do you provide authentication for SOAP Web services?

Authentication can be with username/password - with UsernameToken or certificate based. Since you are Java based - you can use the open source WSO2 Application Server to deploy your service and with few clicks you can secure your service.

What is authentication type available in SOAP message function?

Authentication standardsBasic/Digest/NTLM authentication - Uses HTTP headers to identify users. WS-Security SAML and Username Tokens - SOAP/XML based authentication, passes credentials and assertions in SOAP message headers, optionally signed and encrypted.

How do I connect to SOAP service?

Click Add > New OpenAPI from SOAP service. Click Upload file. Specify the service to include, and then create the API definition. Select the AccountService SOAP service and then click Add a product.


1 Answers

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"; 
like image 148
Martin Costello Avatar answered Sep 22 '22 13:09

Martin Costello