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??

Edi G.
  • 2,432
  • 7
  • 24
  • 33
Geeti
  • 103
  • 1
  • 9

2 Answers2

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.

M.G.E
  • 371
  • 1
  • 10
0

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

Community
  • 1
  • 1
Red Swan
  • 15,157
  • 43
  • 156
  • 238