How to add an HTTP Header to call a webService ?


Jan 12, 2011
Programming Experience

I want to call a WebService that uses an Http Header from VB.Net.

In SoapUI, here is the XML that allows me to check the WS answers :
<soapenv:Envelope xmlns:soapenv="" xmlns:v0="">

And under the Headers bottom tab, I've those values :
Header name : Authorization
Header value : Basic aXBhcmk6MzZkODA1NDEzMzRhODXXXXXXXXXzdlNDBiYmJhYzk=

In my VB.Net code, I tried to call one WS that does not requires this Authorization header.
The code is :

       Dim aaaa As New SR_SD.EntreprisePortClient         'Define aaaa as the Reference Service for the WebService.
        Dim lStatus As SR_SD.StatusReturn       ' Define lStatus as the result of the WS Status
            lStatus = aaaa.status          ' Calls the WS Status and put the result in lStatus
            If lStatus.statusCode <> 3000 Then        ' Check that everything is OK.
                MessageBox.Show("Error while trying to connect." & lStatus.statusMsg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
                MessageBox.Show("Connexion OK")
            End If
        Catch ex As Exception
            MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try

This is working because the Status webService does not requires the Authorization.
But if course, the other WebServices do require it.

So, my question is : How do I change my code to send the Authorization value ? From what I understand, I first must declare that there is this "Authorization" header, and then its value.
How do I do this ?

Thanks for your help.
Top Bottom