How to specify credential in C# when calling a web service?

Hi, I'm using VS2013, asp.net and C#
I added a JAVA SOAP web service by going to Add Service Reference, Advanced, Add Web Reference.  It asked for log in credential and I provided it, this web services doesn't authenticate using Windows credential.  It's another set of userid and password I have.

The problem in my C# code right now is when I run the code to call the api, it gives me 401 error saying I'm not authorized.  Am I to supply credential again in my C# code?  How to do that?  Thank you.
lapuccaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Franck GaspozSoftware Architect, Technical ExpertCommented:
Hi,
using namespace System.Net, you will found a class named NetworkCredential
you have to instantiate an object of these class providing the good credential informations for your web service, thus pass the object to the web service client object.
if your client web service object is named W for instance, the code should like as following :

W.Credentials = new NetworkCredential("username","password");

thus call the wished method on the W object
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
lapuccaAuthor Commented:
This 3rd party vendor Api doesn't use Windows credential.  The Network credential, isn't that just for Windows authentication?

AFter I created this credential, how to I send it to the JAVA SOAP api that I'm calling?  

Thank you.
0
lapuccaAuthor Commented:
Okay, that same credential without adding he 3rd parameter of domain would seem to work because I no longer gets the 401 error. Of course, now I get a brand new error, but that would be another question.  Thank you.
0
Franck GaspozSoftware Architect, Technical ExpertCommented:
You're welcome
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Services

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.