Solved

Creating a Soap Header

Posted on 2008-06-19
2
755 Views
Last Modified: 2013-12-16
Hi i want to add a soap header in the function give below.Could anyone please help me how to add this header


Public Function ProcessRequest(ByVal paymentRequest As RebillPayment, ByVal Proxy As String) As Boolean
 

        

        

        Dim request As HttpWebRequest = CType(HttpWebRequest.Create(_uri), HttpWebRequest)

        If Proxy IsNot Nothing Then

            request.Proxy = New WebProxy(Proxy, True)

        End If

        ' if SOAPAction header is required, add it here... 

        request.Headers.Add("SOAPAction", """""")

        request.Method = "POST"

        request.Timeout = _timeout

        request.ContentType = "application/x-www-form-urlencoded"

        request.KeepAlive = False

        Dim requestBytes As Byte() = System.Text.Encoding.ASCII.GetBytes(paymentRequest.ToXML)

        request.ContentLength = requestBytes.Length
 

        Try

            Dim requestStream As Stream = request.GetRequestStream

            requestStream.Write(requestBytes, 0, requestBytes.Length)

            requestStream.Close()

        Catch

            Return False

        End Try
 

        Dim response As HttpWebResponse = Nothing
 

        Try

            response = CType(request.GetResponse, HttpWebResponse)

        Catch wex As WebException

            If response Is Nothing Then

                Return False

            End If

            response = CType(wex.Response, HttpWebResponse)

            Dim sr As StreamReader = Nothing

            sr = New StreamReader(response.GetResponseStream, System.Text.Encoding.ASCII)

            Dim _wexBody As String = sr.ReadToEnd

            sr.Close()

            Return False

        Catch

            Return False

        End Try
 

        If response.StatusCode = HttpStatusCode.OK Then

            Dim sr As StreamReader = Nothing

            sr = New StreamReader(response.GetResponseStream, System.Text.Encoding.ASCII)

            Dim _serverXml As String = sr.ReadToEnd

            sr.Close()

            Try

                _response = New RebillResponse(_serverXml)

                Return True

            Catch

                Return False

            End Try

        Else

            Return False

        End If

    End Function

Open in new window

0
Comment
Question by:lakshmidurga
2 Comments
 
LVL 2

Expert Comment

by:vjc2003
ID: 21829303
The SOAP request headers depends on which is the web service url/method you are planning to invoke:

In general these are the request params required:
request.Headers.Add("SOAPAction", soapAction)  
request.Method = "POST"
request.Timeout = _timeout
request.ContentType = "text/xml; charset=utf-8"  [assuming you are going to send a xml as post data]
request.ContentLength = requestBytes.Length

You can find out the soapAction for a method by browsing the webservice url/method.


0
 
LVL 7

Accepted Solution

by:
lakshmidurga earned 0 total points
ID: 22004463
close this question
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Definitions and default visual studio colors 5 58
ADO.NET ENTITY DATA MODEL 3 30
Convert an ASPX page into PDF 7 22
Exit the loop 4 31
Using Quotation Marks in PHP This question (http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_28217211.html) seems to come up a lot for developers who are new to PHP.  And it got me thinking, "How can we explain the rule…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video teaches viewers how to create their own website using cPanel and Wordpress. Tutorial walks users through how to set up their own domain name from tools like Domain Registrar, Hosting Account, and Wordpress. More specifically, the order in…
Wufoo.com provides powerful tools for surveying targeted groups, and utilizing data from completed surveys to find trends, discover areas of demand or customer expectation, and make business decisions on products or services.

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now