Using http post in vb code behind

I have a web site that allows users to pay on line.   I signed up for a service that would check the routing number to make sure it was valid before continuing.  They provided me the code below to use to test the routing number.,  My problem is I use vb code behind and dont want to use a seperate form to test the routing number, I want to make it part of the process of making a payment with my vb code behind.  Can someone tell me how to do that.

thanks

<html>
<head>
<title>RoutingTool Verification Form (sample)</title>
<link rel="stylesheet" type="text/css" href="http://secure.routingtool.com/styles/rt.css">
</head>
<body>
<form method="post" action="https://secure.routingtool.com/cgi-bin/weblink.cgi" name="weblink">
<input type="hidden" name="weblinkagentid" value="74305">
<input type="hidden" name="weblinkid" value="">
<input type="hidden" name="resultformat" value="xml">
<input type="hidden" name="user1" value="userdefined1">
<input type="hidden" name="user2" value="userdefined2">

<!-- Other result formats avail: text, xml, html

  <input type="hidden" name="resultformat" value="html">
  <input type="hidden" name="resultformat" value="text">

-->
<table border="0" cellpadding="2" cellspacing="1" width="300">
<tr>
<td><font face="Verdana" color="#000000" size="1">
9 Digit Routing #:
</font>
</td>
<td>
<input type="text" name="routing"  size="20"/>
</td>
</tr>
</table>
<p />
<input type="hidden" name="op" value="process" />
<input type="submit" name="submit" value="Next &gt;&gt; " />
<hr>
<p align="center">
<font face="Verdana" color="#F41200" size="1">RoutingTool&#153; is a trademark
of yourfavorite.com. 
<br />
&copy;Copyright 2005 yourfavorite.com, All rights reserved.
</font>
</p>
</body>
</html>

Open in new window

mgmhicksAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

käµfm³d 👽Commented:
What does the service return to you? HTML? A string indicating success or failure? Something else? How would you code know from the response whether the tool indicated success or failure?
0
mgmhicksAuthor Commented:
<input type="hidden" name="resultformat" value="xml">

<!-- Other result formats avail: text, xml, html

  <input type="hidden" name="resultformat" value="html">
  <input type="hidden" name="resultformat" value="text">
0
käµfm³d 👽Commented:
Then you should be able to do something like:

Using client As New System.Net.WebClient()
    Dim data As New System.Collections.Specialized.NameValueCollection()

    data.Add("weblinkagentid", "74305")
    data.Add("weblinkid", "")
    data.Add("resultformat", "xml")
    data.Add("user1", "userdefined1")
    data.Add("user2", "userdefined2")
    data.Add("routing", your_routing_number)

    Dim responseData() As Byte = client.UploadValues("https://secure.routingtool.com/cgi-bin/weblink.cgi", data)
    Dim xml As String = Text.Encoding.ASCII.GetString(responseData)
    Dim xdoc As New Xml.XmlDocument()
    Dim resultNode As Xml.XmlNode

    xdoc.LoadXml(xml)

    resultNode = xdoc.SelectSingleNode("/xpath/to/the/result/node")

    If resultNode IsNot Nothing Then
        ' do something with result
    End If

End Using

Open in new window


You may need to add in a XmlNamespaceManager if the returned XML has any namespaces defined within it.
0
Amazon Web Services

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

mgmhicksAuthor Commented:
I think we are on to something.  Here is my code, when I run it I get an exception on the loadxml line,  "Data at the root level is invalid.  Line 1, position 1.  Any ideas

Try
            Using client As New System.Net.WebClient()
                Dim data As New System.Collections.Specialized.NameValueCollection()

                data.Add("weblinkagentid", "21554")
                data.Add("weblinkid", "Password")
                data.Add("resultformat", "xml")
                data.Add("user1", "userdefined1")
                data.Add("user2", "userdefined2")
                data.Add("routing", TextBox1.Text)

                Dim responseData() As Byte = client.UploadValues("https://secure.routingtool.com/cgi-bin/weblink.cgi", data)
                Dim xml As String = Text.Encoding.ASCII.GetString(responseData)
                Dim xdoc As New System.Xml.XmlDocument()
                Dim resultNode As System.Xml.XmlNode

                xdoc.LoadXml(xml)

                resultNode = xdoc.SelectSingleNode("/xpath/to/the/result/node")

                If resultNode IsNot Nothing Then
                    ' do something with result
                End If

            End Using
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

Open in new window

0
käµfm³d 👽Commented:
Put a breakpoint on line 17. When it is hit, mouse over "xml" and see what it contains.
0
mgmhicksAuthor Commented:
here is what is in xml

"Unauthorized<br />Referrer: "

Now I had to setup a referr from where the post will come from, testing on a local host, what http reference would I send, our external ip address.

How can I tell what the local host they are receiving from the post is?

thank you again
0
käµfm³d 👽Commented:
A referrer is the URL that made the request to the external page. In your original sample, the referrer would have been that page. You might try putting in the full URL of the original page that you were using when first started all of this.
0
mgmhicksAuthor Commented:
So if I am doing it from localhost would it be http://myipaddress/something.html

thanks
0
mgmhicksAuthor Commented:
So I set the reference to http://localhost:59374/ResidentPortal052013/Administration/RoutingTest.aspx

That is the address that comes up when I run locally.  Still receiving same error.  Been waiting all day for the company to get back to me.  RoutingTool
0
käµfm³d 👽Commented:
I wonder if it's the Referrer field that's actually causing the problem. The <br/> in that statement denotes a line break, so maybe the error message is simply "Unauthorized" and the Referrer part is just informational. Are you certain you are using the credentials provided to you by the service?
0
mgmhicksAuthor Commented:
You may be right, I changed the password and userid and received the same error.  I am sure those are correct, I can get on site with them, so you may be right about the <br>
0
käµfm³d 👽Commented:
Did you have to enter any details about your site or the page that would be making the calls when you signed up for the service? Perhaps if you did, then whatever you entered there is what you need to use.
0
mgmhicksAuthor Commented:
According to the service provider each language has its own way of setting the referrer.  So what I need to be able to do is change the posting referrer in my code to match what I said it would be on their web site.  So how do we change the referrer of the  client object?
0
käµfm³d 👽Commented:
Ah, OK. You can do that in this manner:

Module Module1

    Sub Main()
        Using client As New System.Net.WebClient()
            Dim data As New System.Collections.Specialized.NameValueCollection()

            data.Add("weblinkagentid", "74305")
            data.Add("weblinkid", "")
            data.Add("resultformat", "xml")
            data.Add("user1", "userdefined1")
            data.Add("user2", "userdefined2")

            client.Headers("Referrer", "http://your.site.com/path/to/page.aspx")
            client.Headers.Add("Referrer", "http://your.site.com/path/to/page.aspx")

            Dim responseData() As Byte = client.UploadValues("https://secure.routingtool.com/cgi-bin/weblink.cgi", data)
            Dim xml As String = Text.Encoding.ASCII.GetString(responseData)
            Dim xdoc As New Xml.XmlDocument()
            Dim resultNode As Xml.XmlNode

            xdoc.LoadXml(xml)

            resultNode = xdoc.SelectSingleNode("/xpath/to/the/result/node")

        End Using
    End Sub

End Module

Open in new window


I've added lines 13 and 14. You don't need both; just pick the one that works. I can't remember if Referrer is in the headers collection by default or if you need to add it, so I've demonstrated both approaches.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mgmhicksAuthor Commented:
receiving error "Property access must assing to the property or use its value."

with line


client.Headers("Referrer", "http://your.site.com/path/to/page.aspx")
0
käµfm³d 👽Commented:
Heheh. My screen is too dark. I didn't see the blue squiggly  = )

Corrected:

client.Headers("Referrer") = "http://your.site.com/path/to/page.aspx"

Open in new window

0
mgmhicksAuthor Commented:
here is the link to set this up

https://secure.routingtool.com/cgi-bin/controlpanel.cgi?op=weblink

I would like to get you and just you the userid and password so you can test it out as well.  We are still getting same error.  Can I send you private message?  

Code I am using is below



  Try
            Using client As New System.Net.WebClient()
                Dim data As New System.Collections.Specialized.NameValueCollection()
                '  data.Add("referrer", "http://localhost:59374/ResidentPortal052013/Administration/RoutingTest.aspx")
                data.Add("weblinkagentid", "74305")
                data.Add("weblinkid", "mySecure")
                data.Add("resultformat", "xml")
                data.Add("user1", "userdefined1")
                data.Add("user2", "userdefined2")
                data.Add("routing", TextBox1.Text)


                client.Headers.Add("Referrer", "http://localhost:59374/ResidentPortal052013/Administration/RoutingTest.aspx")

                client.Headers("Referrer") = "http://localhost:59374/ResidentPortal052013/Administration/RoutingTest.aspx"

                Dim responseData() As Byte = client.UploadValues("https://secure.routingtool.com/cgi-bin/weblink.cgi", data)
                Dim xml As String = Text.Encoding.ASCII.GetString(responseData)
                Dim xdoc As New System.Xml.XmlDocument()
                Dim resultNode As System.Xml.XmlNode

                xdoc.LoadXml(xml)

                resultNode = xdoc.SelectSingleNode("/xpath/to/the/result/node")
                MsgBox(resultNode)
                If resultNode IsNot Nothing Then
                    ' do something with result
                End If

            End Using
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

Open in new window

0
käµfm³d 👽Commented:
OK, so at this point I think it's going to be something that you'll need to work out with RoutingTool's support section.
0
mgmhicksAuthor Commented:
this is what I beleive we are looking for, the rest is up to the vendor.

thank you
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.