How to "double post" ???

  • Thread starter Thread starter Assaf
  • Start date Start date
A

Assaf

Hi all,

My client is using an online service provider that processes survey
responses.

After a user fills survey.aspx and presses the OK button, 2 things need to
happen:
1. the data has to be posted behind the scenes to the provider's URL (e.g.,
http://www.surveyprocessingprovider.com/srvy1?field1=response1&field2=response2)
2. the user has to be redirected to thankyou.aspx.

Has anyone done anything like that? Any idea how to make that happen?

TIA.

- Assaf

(apologizing for double-post)
 
Why do you need to double post?

Clicking the button goes to the server, and the event for that button runs.
The event handler first updates the database with the users's data, then
does a Response.Redirect to the 'thank you' page.
 
Marina,

The wrinkle is that the DB is owned by a provider somewhere out on the
internet. The only interaction I have with the database is by posting to a
url, can't use any DB access (ADO.NET, ODBC...).

Any suggestions?

- Assaf
 
Use a WebClient object you can post that way and wait for the response and
then redirect.

System.Net.Webclient is what your looking for.
 
I see what you are saying.

There is a WebRequest class in .NET, look into it. Basically, it allows you
to do a POST using .NET classes and code, which you would be able to put in
your event handler.

Suggest to your provider that they write a web service, instead of having
you post to a web page.
 
I see what you are saying.
There is a WebRequest class in .NET, look into it. Basically, it allows you
to do a POST using .NET classes and code, which you would be able to put in
your event handler.

Suggest to your provider that they write a web service, instead of having
you post to a web page.

First, what do you think a web service essentially is? Yep, posting to a
web page...

Second, the entire world isn't .NET... Web services aren't always a viable
option.
 
First of all, yes it is essentially the same - but not quite. There is no
standard - which is something that web services adhere to. There is a WSDL
file that conforms to standards, web services use SOAP, etc - all very
standardized.

What makes you think that only .NET has web services? Web services are not
exclusive to .NET - nor do I believe was it invented by .NET. A web service
can be written in Java or anything else - it is just about following a
particular standard - the implementation is up to the developer.
 
First of all, yes it is essentially the same - but not quite. There is no
standard - which is something that web services adhere to. There is a WSDL
file that conforms to standards, web services use SOAP, etc - all very
standardized.

Wow...

No standard? Are you serious? So your saying all web requests I make right
now are "hit or miss" with some web servers? Hmmm.. I don't know what those
bast**rds ath W3C were talking about with the whole HTTP standard... I guess
XML is the only standard in existance now...

It amazes me how we ever got along before it...

I reiterate.. its not just essentially the same, it is the same. It is an
HTTP Post made to a server, in which case, in the header it references which
file it wants, in this case for a web service one with an asmx extenion on
it, which cues the web server to find the ISAPI filter for that and parse
it...

It's on port 80, its using http, it just passes XML instead of a different
formatted packet.

As for WDSL and such? if you want me to write up some documentation of how
you can post to my legacy asp 3.0 web page, i, like most others, will be
happy to do so...

Not conforming to standards though... thats just plain old wrong...
What makes you think that only .NET has web services? Web services are not
exclusive to .NET - nor do I believe was it invented by .NET. A web service
can be written in Java or anything else -

I never said .NET was the only one, this is a .net forum is it not? Kind of
silly for me to talk about java. Sure they can be, but they can't be easily
consumed by each other. I haven't programmed java for about a year and
half, but if memory serves me, I couldn't consume a .net web service in it.
As most times you can't consume java web services in .net. At least not the
"standard" way. So making a comparison like that is kind of silly right
now.



it is just about following a
particular standard - the implementation is up to the developer.

Thank you for the lesson in abstraction...
 
I said there was no standard, referring to simply writing ASP pages that
take data. You have no idea how the page expects it's data, or what
arguments it needs. How could you possibly know that there are 3 arguments
called A, B and C - unless the person who wrote the page explicitly tells
you so?

Certainly there is no standard! There is no way you can have a program that
can read your documentation that you wrote up, and understand how to use
your asp page to do what it needs to. As opposed to a WSDL file, which is
standardized, so it can be read and processed. You can write something to
give a list of all methods available, what parameters are used and what
types they are.

Additionally, how do you know what format the response will be sent in? Will
they put it in some sort of proprietary XML format? Will they just simply
return a string "SUCCESS", or "<response>SUCCESS</response>"? Should you
expect a response at all?

You certainly can't do any of that with an ASP page, or someone's
documentation which they wrote up in Word or their own format they thought
of.

..NET makes consuming web services written in .NET easier. But it's not all
that difficult to make a SOAP request to a web services from any language -
to a web service written in any other language. And to dismiss that people
are writing web services in other languages is ridiculous - perhaps the 3rd
party provider in question here doesn't want to use .NET, but they can use
something else to write a web service.

My point is not that web services is some sort of new technology or miracle.
I'm not disagreeing that at it's core it's just an HTTP Post. But because of
the standards created for it, it becomes a ubiquitous tool, that is not tied
to any particular technology

I think you are missing the entire point behind what a web service is, when
it's useful and what it's there for, and that's just too bad.
 
I said there was no standard, referring to simply writing ASP pages that
take data. You have no idea how the page expects it's data, or what
arguments it needs. How could you possibly know that there are 3 arguments
called A, B and C - unless the person who wrote the page explicitly tells
you so?
Certainly there is no standard! There is no way you can have a program that
can read your documentation that you wrote up, and understand how to use
your asp page to do what it needs to. As opposed to a WSDL file, which is
standardized, so it can be read and processed. You can write something to
give a list of all methods available, what parameters are used and what
types they are.

Wow... again you have derailed...

So what if you don't have a tool that generates a wsdl for you, does a web
service simply not work? Your entire argument is based on generated
documentation... and not really even documentation, simply an interface
map... I can still get documentation anywhere, and according to even you,
generate my own soap envelope, I don't need WSDL to do that...
Additionally, how do you know what format the response will be sent in? Will
they put it in some sort of proprietary XML format? Will they just simply
return a string "SUCCESS", or "<response>SUCCESS</response>"? Should you
expect a response at all?

Proprietary xml? isn't that an oxymoron? This is a WDSL argument, not a
web service argument.

WSDL != Web Service.
You certainly can't do any of that with an ASP page, or someone's
documentation which they wrote up in Word or their own format they thought
of.

The communication is the exact same though, post a response to port 80 [or
whatever is chosen..] on a server. It's no different. I think you have
documentation confused with a communications interface...

That and tool mixed up with the word standard...
.NET makes consuming web services written in .NET easier. But it's not all
that difficult to make a SOAP request to a web services from any language -
to a web service written in any other language. And to dismiss that people
are writing web services in other languages is ridiculous - perhaps the 3rd
party provider in question here doesn't want to use .NET, but they can use
something else to write a web service.

Who said they weren't? This is where most programmers mess up, there is no
point in re-engineering a solution that already works to bring it "up to
speed" with current technology. Thats jsut a bad business decision, and one
that the programmer has no authority on.
My point is not that web services is some sort of new technology or
miracle.

You didn't make that great of a point...
I'm not disagreeing that at it's core it's just an HTTP Post. But because of
the standards created for it, it becomes a ubiquitous tool, that is not tied
to any particular technology

Yet you seem to think that no standards existed before it. Again relying on
your WSDL argument.
I think you are missing the entire point behind what a web service is, when
it's useful and what it's there for, and that's just too bad.

When was that a question of what a web service is? Your understanding of
communication within a web service was misguided, I tried to correct that.
This isn't an understanding of web services, simply how they communicate...


Bytes are Bytes dude...


-CJ
CJ Taylor said:
Wow...

No standard? Are you serious? So your saying all web requests I make right
now are "hit or miss" with some web servers? Hmmm.. I don't know what those
bast**rds ath W3C were talking about with the whole HTTP standard... I guess
XML is the only standard in existance now...

It amazes me how we ever got along before it...

I reiterate.. its not just essentially the same, it is the same. It is an
HTTP Post made to a server, in which case, in the header it references which
file it wants, in this case for a web service one with an asmx extenion on
it, which cues the web server to find the ISAPI filter for that and parse
it...

It's on port 80, its using http, it just passes XML instead of a different
formatted packet.

As for WDSL and such? if you want me to write up some documentation of how
you can post to my legacy asp 3.0 web page, i, like most others, will be
happy to do so...

Not conforming to standards though... thats just plain old wrong...


I never said .NET was the only one, this is a .net forum is it not?
Kind
of
silly for me to talk about java. Sure they can be, but they can't be easily
consumed by each other. I haven't programmed java for about a year and
half, but if memory serves me, I couldn't consume a .net web service in it.
As most times you can't consume java web services in .net. At least not the
"standard" way. So making a comparison like that is kind of silly right
now.



it is just about following a
particular standard - the implementation is up to the developer.

Thank you for the lesson in abstraction...


"CJ Taylor" <[cege] at [tavayn] dit commmmm> wrote in message
I see what you are saying.

There is a WebRequest class in .NET, look into it. Basically, it allows
you
to do a POST using .NET classes and code, which you would be able
to
put
in
your event handler.

Suggest to your provider that they write a web service, instead of
having
you post to a web page.

First, what do you think a web service essentially is? Yep, posting
to
a
web page...

Second, the entire world isn't .NET... Web services aren't always a viable
option.


Marina,

The wrinkle is that the DB is owned by a provider somewhere out
on
the
internet. The only interaction I have with the database is by posting
to
a
url, can't use any DB access (ADO.NET, ODBC...).

Any suggestions?

- Assaf

Why do you need to double post?

Clicking the button goes to the server, and the event for that
button
runs.
The event handler first updates the database with the users's data,
then
does a Response.Redirect to the 'thank you' page.

Hi all,

My client is using an online service provider that processes
survey
responses.

After a user fills survey.aspx and presses the OK button, 2 things
need
to
happen:
1. the data has to be posted behind the scenes to the provider's
URL
(e.g.,
http://www.surveyprocessingprovider.com/srvy1?field1=response1&field2=response2)
 
Here's some code I use to post a credit card transaction, which returns to
the caller. You can then redirect to thankyou:
Private Function viaKlixPostTransaction(ByVal trans As
viaKlixTransaction) As String
modErr.EnterFunction("OrderForm.aspx.vb.viaKlixPostTransaction")
Dim sbldr As New StringBuilder
Dim params As NameValueCollection = trans.GetValues
Dim iEnum As IEnumerator = params.Keys.GetEnumerator

' Build the request string from the parameters
Do While iEnum.MoveNext
Dim sKey As String = iEnum.Current
If Not params.Item(sKey) Is Nothing AndAlso
params.Item(sKey).ToString <> "" Then
sbldr.Append(sKey)
sbldr.Append("=")
sbldr.Append(Server.UrlEncode(params.Item(sKey)))
sbldr.Append("&")
End If
Loop
sbldr.Remove(sbldr.Length - 1, 1) 'Remove trailing "&"

'Post the request
Dim dataResponse As String
Dim dataBody As String = sbldr.ToString
Dim webResponse As HttpWebResponse
Dim webRequestStream As System.IO.Stream
Dim webRequest As HttpWebRequest
Dim responseStream As Stream

' Create the RequestStream
Try
webRequest =
webRequest.Create("https://www2.viaklix.com/process.asp")

' Note - "KeepAlive = False" seems to be needed to avoid errors,
apparently caused by the client
' (this application) thinking the connection is being
maintained while the server or
' firewall may disconnect it. Apparently, if the client
doesn't maintain it, it will know
' enough to re-establish it when it needs it.
webRequest.KeepAlive = False

webRequest.Method = "POST"
webRequest.ContentType = "application/x-www-form-urlencoded"

' Create request body
webRequest.ContentLength = dataBody.Length
webRequestStream = webRequest.GetRequestStream()
Catch ex As Exception
modErr.WriteLog("Creating RequestStream: " & ex.ToString, 0)
End Try

' Write the WebRequest
Try
Dim writer As New StreamWriter(webRequestStream)
writer.Write(dataBody)
'TODO - writer.close can probably go into a Finally block...
Try 'Getting an exception on this shouldn't stop us...
writer.Close() 'Closes the StreamWriter and the underlying
stream
Catch ex As Exception
modErr.WriteLog("Writer.Close: " & ex.ToString, 0)
End Try

Catch ex As Exception ' Catches error on writer.write
modErr.WriteLog(ex.ToString, 0)
modErr.WriteLog(dataBody, 1) 'Looking for data dependency
modErr.ExitFunction()
Return Nothing

End Try

' Get the response from viaKlix
Try
webResponse = webRequest.GetResponse()
responseStream = webResponse.GetResponseStream()

Dim readStream As New System.IO.StreamReader(responseStream)
dataResponse = readStream.ReadToEnd

readStream.Close() 'Closes the StreamReader and the underlying
stream

modErr.ExitFunction()
Return dataResponse

Catch ex As Exception
modErr.WriteLog("Reading Response: " & ex.ToString, 0)
modErr.ExitFunction()
Return Nothing
End Try

End Function
 
Back
Top