Login    
 
 
 
 
Text/HTML
  
You are here :: Blogs Saturday, May 19, 2012

Search
Note: This uses the internal blog search engine. The Google search engine is also available at the top of the page.
  
Disclaimer

Please review the site disclaimer before downloading or using content found on this site

  
Categories
  
DEVSHED Blog
As always, I welcome your comments!
Jul 21

Written by: Steve Gray
7/21/2009 8:44 AM  RssIcon

The task here is to pass a username and password to a web service. We want to pass it not as a property of the web service, but in the SOAP header.

First, define the web service call, and give a name to the SoapHeader so that we can refer to it later

<WebMethod(), SoapHeader("myHeaderMemberVariable")> _
Public Function UpdateGP(ByVal doc As String, ByVal db As String, _ 
    ByVal userID As String) As String
    
'validate the username and password
    validateUser(myHeaderMemberVariable.username, myHeaderMemberVariable.password)
    Return ""
 
End Function

 

Next, look at the call from a Win Forms app that calls the web service

 

Private Sub btnUpdateClient_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) _
    Handles btnUpdateClient.Click
 
    Dim webService As localhost.GPConnect = New localhost.GPConnect
    webService.MyHeaderValue = New localhost.MyHeader
    webService.MyHeaderValue.username = "brstest"
    webService.MyHeaderValue.password = "testpass"
    webService.Url = mstrURL
 
    Dim strDoc As String
 
    Dim xDoc As New Xml.XmlDocument
    xDoc.Load("C:\projects\EConnect\tester\xmlDocs\updateClient.xml")
    strDoc = xDoc.InnerXml
 
    Try
 
        webService.UpdateClient(strDoc, "sgray")
        MsgBox("done")
    Catch ex As Exception
        MsgBox(ex.Message)
 
    End Try
 
End Sub

Note that we are assigning the 'username' and 'password' properties

Last, look back at the first piece of code and note how we get references to those properties.

Tags:
Categories:
As always, I welcome your comments!
  
 
 
Home | Products | Blogs | Contact Us | Links | God's Plan
Privacy Statement | Terms Of Use
 
Copyright 2011 by Devshed.us