?
Solved

How to generate XML request and process response

Posted on 2013-06-10
3
Medium Priority
?
424 Views
Last Modified: 2013-06-29
Hi Experts, can someone show me how I can generate a web request in ASP.NET VB and process the response for the data below. I am not sure how to generate the request and send it to the remote server.

Sample Request (XML)
GET https://sandbox.tchng.com/test_parect/api/v1/gettransaction.xml?productid=21&transactionreference=8421941122&amount=300000 HTTP/1.1
UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 4.0.30319.239)
Hash: F6FF2E22F99D93DDDA52D71811FD92B3A71FA1968A66216E0D310DAD

Open in new window


Sample Response (XML)
HTTP/1.0 200 OK
Date: Tue, 30 Oct 2012 16:20:56 GMT
Content-Type: application/xml; charset=utf-8
Content-Length: 552
<TransactionQueryResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><ResponseCode>00</ResponseCode><ResponseDescription>Approved Successful</ResponseDescription><Amount>300000</Amount><CardNumber>6055</CardNumber><MerchantReference>8421941122</MerchantReference><PaymentReference>ZIB|WEB|VNA|15-10-2012|015933</PaymentReference><RetrievalReferenceNumber>000000538268</RetrievalReferenceNumber><SplitAccounts /><TransactionDate>2012-10-15T11:07:54.547</TransactionDate></TransactionQueryResponse>

Open in new window

0
Comment
Question by:takwirirar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 16

Expert Comment

by:Easwaran Paramasivam
ID: 39234470
0
 
LVL 1

Accepted Solution

by:
takwirirar earned 0 total points
ID: 39274079
I am sorry that link doesnt seem to have the information I require.

This is what I was looking for

' Create a request for the URL. 
Dim request As WebRequest = _
WebRequest.Create("urlforpage")
' If required by the server, set the credentials.
request.Credentials = CredentialCache.DefaultCredentials
request.Headers.Add("customheader", "headertext")

' Get the response.
Dim response As WebResponse = request.GetResponse()
' Display the status.
Console.WriteLine(CType(response, HttpWebResponse).StatusDescription)
' Get the stream containing content returned by the server.
Dim dataStream As Stream = response.GetResponseStream()
' Open the stream using a StreamReader for easy access.
Dim reader As New StreamReader(dataStream)

'read the XML response
Dim doc As XmlDocument = New XmlDocument()
doc.LoadXml(reader.ReadToEnd())

Dim ResponseCode As XmlElement = doc.DocumentElement("YourElement")
' Retrieve the value from the ResponseCode element.
Dim responseValue As String = YourElement.InnerXml
'Display the values you require
resp.Text = responseValue


' Clean up the streams and the response.
reader.Close()
response.Close()

Open in new window

0
 
LVL 1

Author Closing Comment

by:takwirirar
ID: 39286449
Other Expert comment was not suffient. After looking around I found the answer.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Here I am going to explain creating proxies at runtime for WCF Service. So basically we use to generate proxies using Add Service Reference and then giving the Url of the WCF service then generate proxy files at client side. Ok, what if something ge…
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

765 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