Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Perl Misc (http://www.velocityreviews.com/forums/f67-perl-misc.html)
-   -   Help with POST request using LWP? (http://www.velocityreviews.com/forums/t884050-help-with-post-request-using-lwp.html)

at 12-06-2003 02:08 AM

Help with POST request using LWP?
 
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

Bob Walton 12-06-2003 02:22 AM

Re: Help with POST request using LWP?
 
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


Ben Morrow 12-06-2003 03:56 AM

Re: Help with POST request using LWP?
 

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] ben@morrow.me.uk


All times are GMT. The time now is 12:34 AM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57