0

after adding url to service reference in C#.net project I am able to access the different methods of the services , the service provider has given me the username and password for authentication ,however while accessing properties I didn't get the fields/properties for username and password (headers). So my question is that how to authenticate such web services?

----------------------------------------code------------------------------------------------------

queryNniNameType obj = new queryNniNameType();

reqtype = new queryNameAvailabilityRequestType();
headerType = new CNR.ServiceReference1.businessDocumentHeaderType();
businessbody = new queryNniNameType(); 

headerType.messageType = "test";
headerType.messageVersion = 2;
headerType.senderType ="sendertype";
headerType.senderId = "381133334535055664"; 
businessbody.proposedName = "asdfsf";  

reqtype.businessDocumentHeader = headerType;
reqtype.businessDocumentBody = businessbody;


nameAvailabilityResponseType nptype = new nameAvailabilityResponseType();
businessDocumentHeaderType bustype = new businessDocumentHeaderType();
req = new ExternalQueryNameAvailabilityClient();

reply = new queryNameAvailabilityReplyType();
reply.businessDocumentBody = nptype;
reply.businessDocumentHeader = bustype;

So where to pass username and password??

5
  • 1
    Please show some code for making the request without authentication. Commented Dec 15, 2014 at 12:34
  • are you using asmx web services? Commented Dec 15, 2014 at 12:35
  • Yes,I am using Soap based web services ,I am just accessing 3rd party services Commented Dec 15, 2014 at 12:38
  • @Codor I have given the code Please refer that Commented Dec 15, 2014 at 12:41
  • Perhaps the answer below ist just right; is this WCF? It seems so. Commented Dec 15, 2014 at 13:00

2 Answers 2

1

It will be like this in WCF Service:

client.ClientCredentials.UserName.UserName = "user";
client.ClientCredentials.UserName.Password = "pass";

and for web service use client's Credentials property instead.

Sign up to request clarification or add additional context in comments.

Comments

0

To providing security to web services and web api almost same thing. Refer this answer I asked before few days and got approach.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.