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
Tags wsdl

Preface:

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

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: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.