Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Help with POST request using LWP?

Reply
Thread Tools

Help with POST request using LWP?

 
 
at
Guest
Posts: n/a
 
      12-06-2003
Thanks for reading.

I am trying to use LWP to logon then send a request to a remote server
and capture its response for further processing.

So far I've been able to perform the initial connect, retrieve a 2nd
URL and login using https and capture a server assigned cookie as a
response.

Now I am attempting to make the actual request which resides in a disk
file.

The specifications state that the request MUST be send in this was:
"The body of the POST request contains the request parameter
NETCONNECT_TRANSACTION and the value is the encoded XML request.
The entire XML request must be encoded using a MIME format called
"x-www-form-urlencoded" format.".

So, based on my very limited LWP knowledge and the best I could gather
from various tech publications, lwpcook, and usenet examples is the
following code snippet:

==========================
my $fname="CX7XML";
open(TFH,"<CX7XML") or die "Cannot Open CX7XML\n";
while(<TFH>) {
$DATA.=chomp($_);
}
close(TFH);
$REQ= POST $URL2;
$REQ->content_type('application/x-www-form-urlencoded');
$REQ->content_length(length($DATA));
$REQ->content('NETCONNECT_TRANSACTION=$DATA');
$RSP=$UA->request($REQ, "CX7RSP");

==========================

What I receive from the host are the following headers:

200 OK
Cache-Control: no-store
Connection: close
Date: Fri, 05 Dec 2003 22:34:58 GMT
Pragma: no-cache
Accept-Ranges: bytes
ETag: "27a4941a-1-4fa-3fc3ed96"
Server: "EWS/1.11"
Content-Length: 1274
Content-Type: text/html
Content-Type: text/html; charset=iso-8859-1
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Last-Modified: Wed, 26 Nov 2003 00:02:30 GMT
Last-Modified: 0
Client-Date: Fri, 05 Dec 2003 22:32:33 GMT
Client-Peer: 205.xxx.xxx.xxx:443
Client-Response-Num: 1
Client-SSL-Cert-Issuer: /C=US/O=RSA Data Security, Inc./OU=Secure
Server Certification Authority
Client-SSL-Cert-Subject: /C=US/ST=California/L=Costa Mesa/O=Xxxxxxxx
Information Solutions Inc/OU=Technology
Operations/CN=stg1-ss1.xxxxxxxx.com
Client-SSL-Cipher: RC4-MD5
Client-SSL-Warning: Peer certificate not verified
Set-Cookie:
ctrust-session-v002b=24oykHnpivFIsykCCrUU4/Xz/g+0B5h+BhQKrvkYqTKVfLTTAeIdEI+y1efpg5oshPz9G7ahhKT dGeh9rwosg0WNZ/vALoSkhK7/phTuI2caRKZAmo0TJgaGMIE7wMdS6y4mQLOTPjOrLSnEOuyKqu psftUAZXXI2R4jkkfs4hPpj+CTJWaXeWVpOI/1OiRbgIRXl3Xy9Lo=;domain=.experian.com;path=/;secure
X-Meta-Description: SSO
X-Meta-Keywords: SSO

And just another "login" screen insteat of a returned XML file that I
would receive if successful.

I've tried literally dozens and dozens of code methods based on LWP
examples but the all end up the same as the current one.

Can anyone with LWP experience PLEASE try to point me to the area that
I might be mis-understanding this process?

Thanks a million.

Bob
 
Reply With Quote
 
 
 
 
Bob Walton
Guest
Posts: n/a
 
      12-06-2003
at Bob Mariotti wrote:

....


Just a guess...


> $REQ->content('NETCONNECT_TRANSACTION=$DATA');


"---------------^----------------------------^
Note that $DATA is not interpolated using '...' quotation.

....
> Bob


--
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl

 
Reply With Quote
 
 
 
 
Ben Morrow
Guest
Posts: n/a
 
      12-06-2003

R.Mariotti(at)FinancialDataCorp.com (Bob Mariotti) wrote:
> $REQ= POST $URL2;
> $REQ->content_type('application/x-www-form-urlencoded');
> $REQ->content_length(length($DATA));
> $REQ->content('NETCONNECT_TRANSACTION=$DATA');


You should be creating your request with:

my $REQ = POST $URL2, [ NETCONNECT_TRANSACTION => $DATA ];

or indeed simply using

my $RSP = post $UA $URL2,
[ NETCONNECT_TRANSACTION => $DATA ],
':content_file' => "CX7RSP";

, either of which will properly deal with URLencoding the XML.

Ben

--
It will be seen that the Erwhonians are a meek and long-suffering people,
easily led by the nose, and quick to offer up common sense at the shrine of
logic, when a philosopher convinces them that their institutions are not based
on the strictest morality. [Samuel Butler, paraphrased] http://www.velocityreviews.com/forums/(E-Mail Removed)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to enter to .aspx page by http connection using http POST request farazkazmi@gmail.com Java 6 08-29-2005 02:58 PM
Problem in using Request and Request.Form norton ASP General 4 08-13-2004 03:02 PM
send XML Request string using POST Matt Java 1 04-21-2004 05:22 PM
Post post post. Shel-hed Computer Support 2 11-08-2003 07:41 AM
Re: Accessing Request.InputStream / Request.BinaryRead *as the request is occuring*: How??? Brian Birtle ASP .Net 2 10-16-2003 02:11 PM



Advertisments