Re: WOHTTPConnection & WORequest
Re: WOHTTPConnection & WORequest
- Subject: Re: WOHTTPConnection & WORequest
- From: David Griffith <email@hidden>
- Date: Thu, 27 Jul 2006 18:43:53 +0200
Hi Jerry,
Well, I have no control over the other website. What I need to do is
this:
In my own WO App, I have a page which displays some information from
the database about a domain name and who it is associated with.
I would like to have a button on that page that can be clicked which
will then send a request to the 3rd party web site (which is just a
standard website). I want to submit a form to it as if I had gone to
the page, entered my details in the form and clicked submit. Except
I don't want to manually enter my details, I want to submit the form
without going to the actual webpage itself (so effectively I want to
create a page that emulates the actual page on that webserver and
submit it with form values filled in already (rather than anyone
having to manually enter them).
Obviously that webserver will return a normal HTTP response page
(HTML page) which is the page that I want to get back to my original
WO App whereupon I will parse it for the information I need and place
that information on my WOComponent as necessary.
I have done this with another programming tool in the past and built
Google's language tools into my own application. I am trying to do
something similar with WebObjects but just can't find the correct way
to do it. Perhaps WebServices is what I need. I will look into it
further.
To give a more step-by-step idea of what I am trying to do:
User looks up a record in my app which contains a variable called
'domainname'.
They click the button that says 'Lookup'.
My WOApp then needs to generate a HTML form that can be submitted
with some form field values to a URL that I specify, but with no user
interaction of any kind.
I need to get the response page (HTML) from that URL back into my WO
App.
From there I have no problem as I can parse it and get the info I need.
Regards,
David.
On 27 Jul 2006, at 17:55, Jerry W. Walker wrote:
Hi, David,
Whew! If I understand you correctly, I'm not sure that's doable,
and if it is, would require a greater network knowledge than my
own. So, here's your requirement as I infer it:
From a WebObjects application at www.xxx.com, you created and sent
out a response to John Smith's browser with the following page:
WOComponent
Form
Field1
Field2
Field3
Field4
...
SubmitButton
If Field3 contains a domain name that John Smith entered into the
form, say "www.yyy.com", you want the browser containing the above
page to send the form values from that page as a standard HTTP
request to www.yyy.com rather than back to your WOApp.
You want some application there (a WO app?) to parse the request
from John Smith's browser for its form values, and to generate a
response that it will somehow smush into a pseudo-request
containing the form values (or some transformation of them) which
it will send directly to your WOApp at www.xxx.com.
Your WOApp (the one which generated the original page to which John
Smith is responding) will accept this pseudo-request from
www.yyy.com, parse the form values therein and send its response
back, not to www.yyy.com, but to John Smith's browser as if it were
responding to the request the browser sent to www.yyy.com.
I'm presuming that you have some control over the application at
www.yyy.com, else how would you get it to take a request from John
Smith's browser and return its response to your app?
If this is a reasonable interpretation of your requirement, then,
if it's doable at all, it's solution will require a grievous
distortion of the standard HTTP network protocols on the part two
web applications and some JavaScript hacking (in the page you
originally sent out) on John Smith's web browser.
Again, if this is your requirement, may I suggest an alternative
approach which will avoid all these distortions?
I suggest that the form be returned to your original WOApp (as
every party in this chain expects), and that your WOApp engage in a
Web Services transaction with the application at www.yyy.com to
send the form values and obtain its parsing services before
returning the expected response to John Smith's browser. Web
Services is set up for exactly this kind of interaction.
If you have no control over the application at www.yyy.com, and it
will only respond to HTTP requests containing standard HTML forms,
it's possible to jimmy up what Web Services can send out from your
WOApp to look like an HTTP request, but I'm not sure how you would
get your WOApp to accept it's response. I'm not that much of a Web
Services guru.
If you have the control over the two web apps to use this approach,
it would work with network protocols appropriately rather than
trying to violate them, and would probably provide you with a good
deal more flexibility in your parsing and response. Additionally,
down the line, when the requirements change, you can address the
changed requirements immediately within the architecture rather
than taking a long backwards step to figure out what the H*** was
going on here between this browser and these two systems before
even looking at the changes requested. And if you're not the one
making the changes, you might save your own skin from the enmity of
the programmer who follows you into this mine field.
Sorry I couldn't provide more direct help to your question.
Regards,
Jerry
On Jul 27, 2006, at 10:40 AM, David Griffith wrote:
Hi Jerry,
Thanks for the detailed response. Actually I am already aware of
all of this and no I don't find the answer patronising as it is
great to see someone answer any question in such detail!
However, what I am trying to do is this:
On a WOComponent that already exists and contains a domain name in
one of the form fields, I want to have a button that when clicked
will take the domain name from the existing field (or variable) on
the WOComponent, construct a page that can be submitted
transparently to another server (not the WO server) and receive a
response from that server which I can then parse and display the
relevant pieces of information on the original WOComponent.
Kind regards,
David.
On 27 Jul 2006, at 16:00, Jerry W. Walker wrote:
Hi, David,
Are you asking how to submit a form to a WOApplication from one
of its WOComponents? Or are you asking for something much more
involved?
If your question is the former, then do the following:
* Create a WOForm in your WOComponent.
* Embed all the WOForm elements that take form values
(WOTextField, WOTextArea, WOCheckBox, etc.) within that form
along with at least one WOSubmitButton or WOImageButton. This is
most easily done using WebObjects Builder.
* If you are using multiple submit and/or image buttons, be
sure to set the multipleSubmit binding on your WOForm to true.
* Bind each of your WOForm elements to keys (iVar or method
names) in your WOComponent's Java file.
* Bind each of your submit and/or image buttons to an action
method in your Java file (a method that takes no arguments and
returns a WOComponent value representing the page you want
displayed when that button is clicked).
* Vend the page (WOComponent containing your WOForm).
When the user fills out your form fields and clicks on the submit
button, the browser sends the page with an HTML POST request. The
WOAdaptor turns the HTML request into a WORequest and sends it to
your application in the first two of the following three messages
of the Request/Response cycle:
* takeValuesFromRequest - which WO uses to extract the values
from any of the form elements (contained in the form that also
contains the button that was clicked) and automatically inserts
them into the bound elements of your code.
* invokeAction - which WO uses to identify the submit button
element that was clicked and messages the action method which
you've bound to that submit button.
* appendToResponse - which WO uses to build a WOResponse that
the WOAdaptor translates into HTML and sends out through the web
server to render the next page.
The next page is determined by which page your action method
returns. You can put anything you want on that next page,
including only the values of the form elements of the previous
page containing the WOForm.
All of this automatic behavior is built into WO and you don't
have to do anything explicit like creating a WOHTTPConnection or
a WORequest. These are done for you. If this answers your
question, then I strongly urge you to go through the WO tutorials
and introductory material, otherwise you will end up misusing WO
and hating it.
If you are asking for something much more sophisticated than that
(like sending the page to a different server dynamically chosen
at the time the button is clicked, or something), then you will
have to be much more explicit about what you're trying to do when
you ask the question.
I hope that you didn't find the above information patronizing,
but if yours was a simple question, then that should answer it
without another round of "What are you really trying to do?" If
it wasn't a simple question, hit us again.
Regards,
Jerry
On Jul 27, 2006, at 9:29 AM, David Griffith wrote:
Hi Paul,
Because ultimately I will be submitting values that are already
part of the WO app and will be parsing the response to get the
various values I need. I do not want the user to see the actual
response page, only the pieces that I will extract from the
response.
Kind regards,
David.
On 27 Jul 2006, at 14:50, Paul Suh wrote:
On Jul 27, 2006, at 7:36 AM, David Griffith wrote:
Hi all,
I want to allow a user to enter details into a HTML Form (in a
WOComponent) and when they click the Submit button, I would
like to open a connection to a standard HTTP server with a
specific URL and pass it the form values that the user
entered. Can someone tell me an easy way to do this? I can
create the WOHTTPConnection but I think I need a WORequest to
send to it and I can't figure out how to get the form values
into that request. It's probably easy I'm sure :-)
David,
Stupid question, but is there a particular reason why you need
to send it through your WO app? Why not point your form's URL
straight to the other HTTP server?
--Paul
Paul
Suh
http://www.ps-enable.com/
email@hidden (240) 672-4212
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden
This email sent to email@hidden
--
__ Jerry W. Walker,
WebObjects Developer/Instructor for High Performance
Industrial Strength Internet Enabled Systems
email@hidden
203 278-4085 office
--
__ Jerry W. Walker,
WebObjects Developer/Instructor for High Performance Industrial
Strength Internet Enabled Systems
email@hidden
203 278-4085 office
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden