How to call the Web ser Based on Basic Authentication/digest authentication/Windows authencation Authentication Mode and provide the client certificate

Source: Internet
Author: User


When the client fails to carry non-anonymous authentication modes such as Basic Authentication/digest authentication in IIS, the client must provide the corresponding credential.

Important Notes:

1. How to generate proxy class

When using the WSDL command, you must provide the user name and password connected to the Web service to generate proxy. The syntax is as follows:

WSDL http: // WebService-Uri/WebService. asmx/Username: yourusername/password: yourpassword

2. How to submit client credential and certificate in the client application.

In order to submit the credential of the client, we must create a credential of the client, and then submit it to the server together with the proxy instance for verification, as shown below:

Service1 proxy = new service1 ();

System. net. networkcredential credential = new system. net. networkcredential ("yourusername", "yourpassword", "yourdomain ");

Proxy. Credentials = credential;

Then we need to specify the client's Certificate (public-key part), as follows:

System. Security. cryptography. x509certificates. x509certificate Cert = new system. Security. cryptography. x509certificates. x509certificate ("yourcertificate-publickey.cer ");

Proxy. clientcertificates. Add (CERT );

In this way, the client provides credential and certificate and submits them together to the server. :) of course, everything above is done, the precondition is that the Web Service server is configured in the basic/digest authencation + certificate mode.

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

11.11 Big Sale for Cloud

Get Unbeatable Offers with up to 90% Off,Oct.24-Nov.13 (UTC+8)

Get It Now >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.