Can someone help me sort this one out and quick?

Can someone help me sort this one out and quick?

am 29.01.2008 22:18:57 von Brent White

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:


ACTION="https://developer.skipjackic.com/scripts/evolvcc.dll ?
SJAPI_TransactionStatusReque
st" METHOD=POST>





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.

Re: Can someone help me sort this one out and quick?

am 29.01.2008 22:59:17 von Jurjen de Groot

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:6e986695-230f-4edd-9b61-38eb5167bc1b@c4g2000hsg.googleg roups.com...
> 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:
>
>
> > ACTION="https://developer.skipjackic.com/scripts/evolvcc.dll ?
> SJAPI_TransactionStatusReque
> st" METHOD=POST>
>
>
>
>
>
> 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.
>

RE: Can someone help me sort this one out and quick?

am 30.01.2008 18:28:03 von pbromberg

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:
>
>
> > ACTION="https://developer.skipjackic.com/scripts/evolvcc.dll ?
> SJAPI_TransactionStatusReque
> st" METHOD=POST>
>
>
>
>
>
> 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.
>
>