WebService security authentication based on SoapHeader (II.)

Source: Internet
Author: User

Supports calling WebService via HTTP request method, while supporting SoapHeader authentication.

usingGlobalegrow.common;usingGlobalegrow.model;usingsystem.web;usingSystem.Web.Services.Protocols;namespaceglobalegrow.service{/// <summary>    ///custom SoapHeader class. /// </summary>     Public classCertificate:soapheader {Private StaticServiceConfig M_serviceconfig; /// <summary>        ///constructor Function/// </summary>         PublicCertificate () {The//=> is used to handle the SoapHeader information required to validate the HTTP request to invoke the WebService service. This.            UserName = httpcontext.current.request["UserName"]; This. PassWord = httpcontext.current.request["PassWord"]; }        /// <summary>        ///Static Constructors/// </summary>        StaticCertificate () {//= = When you create an instance of the certificate class, assign a value to Appcontext.serviceconfigM_serviceconfig =serviceconfigutility.load (); Appcontext.serviceconfig=M_serviceconfig; }        /// <summary>        ///User name/// </summary>         Public stringUserName {Get;Set; } /// <summary>        ///Password/// </summary>         Public stringPassWord {Get;Set; } /// <summary>        ///user authentication/// </summary>         Public BOOLIsvaild ( out stringmessage) {            string_username =M_serviceconfig.webservicetokenaccount; string_password =M_serviceconfig.webservicetokenpassword; if( This. UserName = = _username && This. PassWord = =_password) {Message=""; return true; }            Else{message="Sorry, you do not have permission to call this service! "; return false; }        }    }}

Call:

http://192.168.3.41:8888/permissionservice/permissionservice.asmx/getauthuserbyroleid? Username=admin&password=admin&roleid=11

WebService security authentication based on SoapHeader (II.)

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.