Chetan
Chetan

Reputation: 21

Setting ClientCredentials: getting "Username is not provided" error

I'm tasked with creating a WCF service from a local wsdl file. I have done some R&D on this task. I have added a web reference of that local wsdl file. Now I want to create a client for this service in order access the service.

How do I provide the username and password in the client?

Currently, when I am accessing the service methods in the client I get an error:

Username is not provided.

Here's the relevant code:

 ServiceGetProductFeeds.ProductFeedServiceClient  SerProdFeeds = new ServiceGetProductFeeds.ProductFeedServiceClient();
 SerProdFeeds.ClientCredentials.UserName.UserName = "XXXXXX";
 SerProdFeeds.ClientCredentials.UserName.Password = "*******";
 SerProdFeeds.getProductFeed(); 

Any tips on what's not correct with the above code?

Upvotes: 2

Views: 20521

Answers (1)

Praburaj
Praburaj

Reputation: 11537

Do you have security mode, clientCredentialtype configured appropriately in your configuration files? Here is a blog post that very closely matches your question. I hope this helps!

http://amadotech.blogspot.com/2009/11/error-username-is-not-provided-specify.html

Actually there're three causes with my application:

  1. Security mode was not appropriae.
  2. Client credential type was not appropriate.
  3. The call missed passing the required Username and password.

Upvotes: 1

Related Questions