Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HTTP POST 1

Status
Not open for further replies.

thisismondweep

Programmer
Apr 29, 2007
28
Hi,

I want to post form data to a website, from within a DSTX map, and expect to receive the server's response.

For example: GET("HTTP",
"-URL -METHOD POST -TV -TYPE application/x-
The form has six text boxes. I want to pass the values of the six text boxes (say 'hi')and retrive the response.

I would appreciate any help in this regards.

The response from the server should be a html page containing for example:-

field 1=hi,field 2=hi,field 3=hi,field 4=hi,field 5=hi,field 6=hi



Cheers,
Mondweep.
 
Whats the problem you are having - are you asking how to fill the form in or how to interpret the HTML coming back?

If the website can provide an API (e.g. SOAP or REST) then you'll find it a lot easier in the long run than the current screen scraping you're using (which may break if a minor front-end change is made).

 
OllyC,

Thanks for your response. Actually, we are required to test the TX HTTP adapter using the POST verb. Therefore, I want to pass values for the six text-boxes to the server. I have gone through the documentation but am unsure about the exact way to POST information to the server.

[I have tried GET and it works; but want to do it via a POST]
 
Typically you'd do a HTTP POST but using XML and get back an XML in response. POSTing to fields is a bit risky - but I guess everyone's requirements are different.

A good example is in the http.mms map in the examples folder, see the httppost map.

basically you post to whatever URL the submit button is pointed at. the text you post is a single string consisting of field name and value pairs, e.g.:

field1=value1&field2=value2field3=value3

also specify a TYPE of application/x-
 
Hi,

I have had tried the above approach earlier using POST. It just retrieves the initial form from the server.Visually, there seems to be no difference between passing the name=value pairs and not passing them.

Is it possible, via TX,to emulate the normal process (in Internet Explorer) of
1)entering the values in the form elements and
2)then submitting the information to the server
3)Getting the response from the server.

Cheers,
Mondweep.
 
>Is it possible, via TX,to emulate the normal process

yes, this is exactly what you are doing in passing field and value pairs.

>It just retrieves the initial form from the server.

sounds like you're sending the query to the wrong URL. Have a look at the source code for the form screen, there should be a submit button thats linked to another URL - its that URL that you want to post to.
 
OllyC,

Yes, the action parameter in the html was '/servlet/z.servlets.EchoServlet'. So, the values I passed were not being posted to the servlet.

However, even with posts like:-
GET("HTTP",
"-URL -METHOD POST -TV -TYPE application/x-
I get a response like:-

This is the return message from your input.

Input URL /echoRequest.jsp
Input method POST
Input content length 0
Input content type application/x-Input protocol HTTP/1.1
Secure ? false
Server name 128.30.112.95
Remote address 128.30.80.129
Requested URI /echoRequest.jsp
Parameter Names List:
field1 = 'hi1'

Input request java object: com.ibm.ws.webcontainer.srt.SRTServletRequest@739fe1cb


The 'Input content length 0' is zero. Is it possible to send data in POST via TX that does not go via the URL?

Cheers,
Mondweep.
 
Hi,

Just to clarify what I wrote above, I meant is it possible to send data that goes as a payload and not just as part of the URL?

Cheers,
Mondweep.

 
Hi,

Yes I believe it can be done like:-

= GET("HTTP",
"-URL -METHOD POST -TV -TYPE application/x- "Hello,hi")

What we would now be doing is send an XML as the payload to the HTTP Post. The backend will be processing the XML and respond to us.

Thank you very much for your help!

Cheers,
Mondweep.
 
I'm not sure that I totally understand :) but glad you got it to work!

 
one last note, if you are POSTing in an XML document (and no field value pairs etc.), its best to specify a type of "text/xml" rather than "application/x-
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top