Can someone help me sort this one out and quick?

Discussion in 'ASP .Net' started by Brent White, Jan 29, 2008.

  1. Brent White

    Brent White Guest

    Greatly appreciated in advance.

    I am constructing a web service in VB.NET and the primary function
    works terrifically, no problems.

    Now, I am trying to extend the functionality by having the web service
    call a function, also VB.NET, that direct posts a form to an external
    page. They are expecting name/value pairs in the request. The first
    part of the VB.NET used an API call to the web server outside our
    company. The form they are expecting is something along the lines of:

    <!--Fixed Values-->
    <FORM NAME="samplegettransactionstatus"
    ACTION="https://developer.skipjackic.com/scripts/evolvcc.dll?
    SJAPI_TransactionStatusReque
    st" METHOD=POST>
    <INPUT NAME="szSerialNumber" VALUE="123456789102">
    <INPUT NAME="szDeveloperSerialNumber" VALUE="123456789102">
    <!--Purchase Data-->
    <INPUT NAME="szOrderNumber" VALUE="9999999999">

    What I am doing is passing the serial number, developer serial number
    and the order number to a function within the service1.asmx.vb code.
    The code is written right now as follows:

    Function GetTransactionStatus(ByVal OrderNumber As String, ByVal
    HTMLSerial As String, ByVal Developserial As String, ByVal
    WWW_OR_DEVELOPER As String) As String
    Dim whrstat As System.Net.HttpWebRequest
    whrstat = System.Net.WebRequest.Create("https://" &
    WWW_OR_DEVELOPER & ".skipjackic.com/scripts/evolvcc.dll?
    SJAPI_TransactionStatusRequest")
    Dim sb2 As New StringBuilder()
    'Return "Hi, this page is served by Brent White's own system
    and can be looked at " & Input1.SecondParam & " times."
    'Return Input1.SerialNumber
    sb2.Append("szSerialNumber=" & UrlEncode(HTMLSerial) & "&")
    'qString = qString & "SerialNumber=" &
    HtmlEncode(Input1.SerialNumber) & "&"
    'Return Input1.Dev_SerialNumber
    sb2.Append("szDeveloperSerialNumber=" &
    UrlEncode(Developserial) & "&")
    sb2.Append("szOrderNumber=" & UrlEncode(OrderNumber))
    Dim datastat
    Dim datareqstat As Byte()
    Dim encodingstat As New ASCIIEncoding
    datastat = ""
    'Return sb2.ToString
    datareqstat = encodingstat.GetBytes(sb2.ToString)
    whrstat.Headers("szSerialNumber") = HTMLSerial
    whrstat.Headers("szDeveloperSerialNumber") = Developserial
    whrstat.Headers("szOrderNumber") = OrderNumber
    whrstat.Method = "POST"
    'whrstat.ContentType = "application/x-www-form-urlencoded"
    'whrstat.ContentLength = datareqstat.Length
    Dim requeststreamstat As System.IO.Stream
    requeststreamstat = whrstat.GetRequestStream()
    'requeststream.Write(data, 0, datareq.ToString.Length)
    requeststreamstat.Write(datareqstat, 0, datareqstat.Length)
    requeststreamstat.Close()
    'On Error Resume Next
    'whr.send(qString)
    Dim responsestreamstat As System.Net.HttpWebResponse
    responsestreamstat = whrstat.GetResponse
    'responsestream.GetResponseStream()
    'starttime = DateTime.Now
    Dim srstat As System.IO.StreamReader
    srstat = New
    System.IO.StreamReader(responsestreamstat.GetResponseStream)
    Return srstat.ToString


    End Function

    I know I have something set wrong, but I can't make heads or tails of
    what exactly I should be doing. When I run this, calling the function
    with the requisite variables, VS2005 goes into a "running" state
    forever. Only thing I can figure out, and let me know if I'm wrong,
    is that it's not posting properly to the external web application and
    never getting a response.

    You guys have been great in helping me get a better grasp of VS.NET in
    general, and I appreciate it, but I'm very pressed for time and need
    to get some kind of code going ASAP. Searching the Internet is futile
    because no matter what I enter for the search criteria, I get a ton of
    irrelevant pages or no pages at all.

    If it helps, this is VB.NET code.
    Brent White, Jan 29, 2008
    #1
    1. Advertising

  2. I'm not familiar with how to GET or POST data to a site, but have you tried
    'googling' on http://www.searchdotnet.com instead of google ? the results on
    this search engine are much specific to dotnet and I use it all the time.

    I found this link http://forums.devx.com/showthread.php?t=154829 (amongst
    many others) using the following search phrase : "HTTP POST" using VB.NET

    HTH,
    Jurjen.


    "Brent White" <> wrote in message
    news:...
    > Greatly appreciated in advance.
    >
    > I am constructing a web service in VB.NET and the primary function
    > works terrifically, no problems.
    >
    > Now, I am trying to extend the functionality by having the web service
    > call a function, also VB.NET, that direct posts a form to an external
    > page. They are expecting name/value pairs in the request. The first
    > part of the VB.NET used an API call to the web server outside our
    > company. The form they are expecting is something along the lines of:
    >
    > <!--Fixed Values-->
    > <FORM NAME="samplegettransactionstatus"
    > ACTION="https://developer.skipjackic.com/scripts/evolvcc.dll?
    > SJAPI_TransactionStatusReque
    > st" METHOD=POST>
    > <INPUT NAME="szSerialNumber" VALUE="123456789102">
    > <INPUT NAME="szDeveloperSerialNumber" VALUE="123456789102">
    > <!--Purchase Data-->
    > <INPUT NAME="szOrderNumber" VALUE="9999999999">
    >
    > What I am doing is passing the serial number, developer serial number
    > and the order number to a function within the service1.asmx.vb code.
    > The code is written right now as follows:
    >
    > Function GetTransactionStatus(ByVal OrderNumber As String, ByVal
    > HTMLSerial As String, ByVal Developserial As String, ByVal
    > WWW_OR_DEVELOPER As String) As String
    > Dim whrstat As System.Net.HttpWebRequest
    > whrstat = System.Net.WebRequest.Create("https://" &
    > WWW_OR_DEVELOPER & ".skipjackic.com/scripts/evolvcc.dll?
    > SJAPI_TransactionStatusRequest")
    > Dim sb2 As New StringBuilder()
    > 'Return "Hi, this page is served by Brent White's own system
    > and can be looked at " & Input1.SecondParam & " times."
    > 'Return Input1.SerialNumber
    > sb2.Append("szSerialNumber=" & UrlEncode(HTMLSerial) & "&")
    > 'qString = qString & "SerialNumber=" &
    > HtmlEncode(Input1.SerialNumber) & "&"
    > 'Return Input1.Dev_SerialNumber
    > sb2.Append("szDeveloperSerialNumber=" &
    > UrlEncode(Developserial) & "&")
    > sb2.Append("szOrderNumber=" & UrlEncode(OrderNumber))
    > Dim datastat
    > Dim datareqstat As Byte()
    > Dim encodingstat As New ASCIIEncoding
    > datastat = ""
    > 'Return sb2.ToString
    > datareqstat = encodingstat.GetBytes(sb2.ToString)
    > whrstat.Headers("szSerialNumber") = HTMLSerial
    > whrstat.Headers("szDeveloperSerialNumber") = Developserial
    > whrstat.Headers("szOrderNumber") = OrderNumber
    > whrstat.Method = "POST"
    > 'whrstat.ContentType = "application/x-www-form-urlencoded"
    > 'whrstat.ContentLength = datareqstat.Length
    > Dim requeststreamstat As System.IO.Stream
    > requeststreamstat = whrstat.GetRequestStream()
    > 'requeststream.Write(data, 0, datareq.ToString.Length)
    > requeststreamstat.Write(datareqstat, 0, datareqstat.Length)
    > requeststreamstat.Close()
    > 'On Error Resume Next
    > 'whr.send(qString)
    > Dim responsestreamstat As System.Net.HttpWebResponse
    > responsestreamstat = whrstat.GetResponse
    > 'responsestream.GetResponseStream()
    > 'starttime = DateTime.Now
    > Dim srstat As System.IO.StreamReader
    > srstat = New
    > System.IO.StreamReader(responsestreamstat.GetResponseStream)
    > Return srstat.ToString
    >
    >
    > End Function
    >
    > I know I have something set wrong, but I can't make heads or tails of
    > what exactly I should be doing. When I run this, calling the function
    > with the requisite variables, VS2005 goes into a "running" state
    > forever. Only thing I can figure out, and let me know if I'm wrong,
    > is that it's not posting properly to the external web application and
    > never getting a response.
    >
    > You guys have been great in helping me get a better grasp of VS.NET in
    > general, and I appreciate it, but I'm very pressed for time and need
    > to get some kind of code going ASAP. Searching the Internet is futile
    > because no matter what I enter for the search criteria, I get a ton of
    > irrelevant pages or no pages at all.
    >
    > If it helps, this is VB.NET code.
    >
    Jurjen de Groot, Jan 29, 2008
    #2
    1. Advertising

  3. The WebClient class in System.Net has an UploadValues method that accepts a
    handy NameValueCollection of the form itemnames and values to make a form
    POST.
    -- Peter
    Site: http://www.eggheadcafe.com
    UnBlog: http://petesbloggerama.blogspot.com
    MetaFinder: http://www.blogmetafinder.com


    "Brent White" wrote:

    > Greatly appreciated in advance.
    >
    > I am constructing a web service in VB.NET and the primary function
    > works terrifically, no problems.
    >
    > Now, I am trying to extend the functionality by having the web service
    > call a function, also VB.NET, that direct posts a form to an external
    > page. They are expecting name/value pairs in the request. The first
    > part of the VB.NET used an API call to the web server outside our
    > company. The form they are expecting is something along the lines of:
    >
    > <!--Fixed Values-->
    > <FORM NAME="samplegettransactionstatus"
    > ACTION="https://developer.skipjackic.com/scripts/evolvcc.dll?
    > SJAPI_TransactionStatusReque
    > st" METHOD=POST>
    > <INPUT NAME="szSerialNumber" VALUE="123456789102">
    > <INPUT NAME="szDeveloperSerialNumber" VALUE="123456789102">
    > <!--Purchase Data-->
    > <INPUT NAME="szOrderNumber" VALUE="9999999999">
    >
    > What I am doing is passing the serial number, developer serial number
    > and the order number to a function within the service1.asmx.vb code.
    > The code is written right now as follows:
    >
    > Function GetTransactionStatus(ByVal OrderNumber As String, ByVal
    > HTMLSerial As String, ByVal Developserial As String, ByVal
    > WWW_OR_DEVELOPER As String) As String
    > Dim whrstat As System.Net.HttpWebRequest
    > whrstat = System.Net.WebRequest.Create("https://" &
    > WWW_OR_DEVELOPER & ".skipjackic.com/scripts/evolvcc.dll?
    > SJAPI_TransactionStatusRequest")
    > Dim sb2 As New StringBuilder()
    > 'Return "Hi, this page is served by Brent White's own system
    > and can be looked at " & Input1.SecondParam & " times."
    > 'Return Input1.SerialNumber
    > sb2.Append("szSerialNumber=" & UrlEncode(HTMLSerial) & "&")
    > 'qString = qString & "SerialNumber=" &
    > HtmlEncode(Input1.SerialNumber) & "&"
    > 'Return Input1.Dev_SerialNumber
    > sb2.Append("szDeveloperSerialNumber=" &
    > UrlEncode(Developserial) & "&")
    > sb2.Append("szOrderNumber=" & UrlEncode(OrderNumber))
    > Dim datastat
    > Dim datareqstat As Byte()
    > Dim encodingstat As New ASCIIEncoding
    > datastat = ""
    > 'Return sb2.ToString
    > datareqstat = encodingstat.GetBytes(sb2.ToString)
    > whrstat.Headers("szSerialNumber") = HTMLSerial
    > whrstat.Headers("szDeveloperSerialNumber") = Developserial
    > whrstat.Headers("szOrderNumber") = OrderNumber
    > whrstat.Method = "POST"
    > 'whrstat.ContentType = "application/x-www-form-urlencoded"
    > 'whrstat.ContentLength = datareqstat.Length
    > Dim requeststreamstat As System.IO.Stream
    > requeststreamstat = whrstat.GetRequestStream()
    > 'requeststream.Write(data, 0, datareq.ToString.Length)
    > requeststreamstat.Write(datareqstat, 0, datareqstat.Length)
    > requeststreamstat.Close()
    > 'On Error Resume Next
    > 'whr.send(qString)
    > Dim responsestreamstat As System.Net.HttpWebResponse
    > responsestreamstat = whrstat.GetResponse
    > 'responsestream.GetResponseStream()
    > 'starttime = DateTime.Now
    > Dim srstat As System.IO.StreamReader
    > srstat = New
    > System.IO.StreamReader(responsestreamstat.GetResponseStream)
    > Return srstat.ToString
    >
    >
    > End Function
    >
    > I know I have something set wrong, but I can't make heads or tails of
    > what exactly I should be doing. When I run this, calling the function
    > with the requisite variables, VS2005 goes into a "running" state
    > forever. Only thing I can figure out, and let me know if I'm wrong,
    > is that it's not posting properly to the external web application and
    > never getting a response.
    >
    > You guys have been great in helping me get a better grasp of VS.NET in
    > general, and I appreciate it, but I'm very pressed for time and need
    > to get some kind of code going ASAP. Searching the Internet is futile
    > because no matter what I enter for the search criteria, I get a ton of
    > irrelevant pages or no pages at all.
    >
    > If it helps, this is VB.NET code.
    >
    >
    Peter Bromberg [C# MVP], Jan 30, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Miguel Dias Moura
    Replies:
    3
    Views:
    4,293
    Bruno Sirianni
    Apr 3, 2004
  2. Troy
    Replies:
    0
    Views:
    378
  3. emekadavid

    can someone help me out

    emekadavid, May 20, 2008, in forum: Java
    Replies:
    0
    Views:
    305
    emekadavid
    May 20, 2008
  4. Navin
    Replies:
    1
    Views:
    690
    Ken Schaefer
    Sep 9, 2003
  5. Sia
    Replies:
    24
    Views:
    260
    Nick Mellor
    Jan 7, 2013
Loading...

Share This Page