Page view counter

These tutorials demonstrate selected features in ASP.NET version 2.0, but they are compatible with later versions of ASP.NET as well. For the current documentation, see the ASP.NET portal on the MSDN Web site.

 

 

   Welcome   |   ASP.NET   |   Web Services   |   Class Browser   
  |   I want my samples in...      

ASP.NET Web Services QuickStart Tutorial

SOAP Headers

This sample demonstrates the use of ASP.NET Web Services's support for SOAP headers. The sample employs an authorization header sent with the request that has username/password information. The first call to the WebMethod does not include the SOAP header and thus fails. The second call to the WebMethod includes the SOAP header and thus returns successfully.

WARNING: This sample is for demonstration purposes only. Username/password information is sent in plain text, which should never be done in a real application. It is not secure without modification.

		
' On the server, create the AuthHeader class which extends from SoapHeader	
Public Class AuthHeader : Inherits SoapHeader
    Public Username As String
    Public Password As String
End Class
    
'On the client, create a new instance of the AuthHeader class
Dim myHeader As New AuthHeader

'WARNING: This sample is for demonstration purposes only.  Username/password information is sent in plain text,
'which should never be done in a real application. It is not secure without modification.  
myHeader.Username = "JaneDoe"
myHeader.Password = "password"

' Set the AuthHeader public member of the Web service instance to myHeader
service.AuthHeaderValue = myHeader
	
' Call the Web service, which automatically sends the header with the request
Dim answer As String = service.HelloWorld()
VB

Run VB Sample
Run Sample View Source



Microsoft .NET Framework SDK QuickStart Tutorials Version 2.0
Copyright � 2005 Microsoft Corporation. All rights reserved.