[Original] IssueVision study notes (1) ----- use SoapHeader to pass Web Seri

Source: Internet
Author: User
Tags web services
When calling Web Serivices, identity authentication is often required so that authenticated users can call methods in Web Serivices. of course, you can add parameters to each Web services method that requires a custom authentication scheme, which requires a lot of effort. issueVision uses a very common and effective and convenient method ----- use SoapHeader to transmit custom authentication data.
SoapHeader provides a method for transferring data to or from the Web services method. The condition is that the data is not directly related to the main function of the Web services method. you do not need to add parameters to each Web services method that requires a custom authentication scheme. Instead, you can apply SoapHeaderAttribute that references classes derived from SoapHeader to each Web services method. The implementation of classes derived from SoapHeader processes the custom identity authentication scheme. IssueVision uses this capability of SoapHeader to implement data transmission for custom identity authentication.
Let's take a look at how to use SoapHeader to transmit data.
1. First, you need to define a class derived from SOAPHeader in the service to indicate the data imported into the SOAP header.
IssueVision implements the first step in the IssueVisionWeb project (this project is used to publish Web Services) by creating the CredentialSoapHeader class.
CredentialSoapHeader. cs
Using System. Web. Services. Protocols;
Namespace IssueVision. Web
Public class CredentialSoapHeader: SoapHeader
Private string m_username;
Private string m_password;
Public string Username
Get {return m_username ;}
Set {m_username = value ;}
Public string Password
Get {return m_password ;}
Set {m_password = value ;}

2. Declare the public field of the service as this type so that the SoapHeader is disclosed in the public contract of Web Services and can be used by the client when a proxy is created.
IssueVision Web Services ---- IssueVisionServices. asmx is implemented in this way.

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.