Help with POST request using LWP?

A

at

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+y1efpg5oshPz9G7ahhKTdGeh9rwosg0WNZ/vALoSkhK7/phTuI2caRKZAmo0TJgaGMIE7wMdS6y4mQLOTPjOrLSnEOuyKqupsftUAZXXI2R4jkkfs4hPpj+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
 
B

Bob Walton

at Bob Mariotti wrote:

....


Just a guess...

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

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

....
 
B

Ben Morrow

R.Mariotti(at)FinancialDataCorp.com (Bob Mariotti) said:
$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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,740
Latest member
AdolphBig6

Latest Threads

Top