argos has asked for the wisdom of the Perl Monks concerning the following question:
I am trying to post some xml to a web service but when I do this my browser returns and error about the format of my xml. However, if I try this from a command line I get what I expect in return. I think the issue might be related to the format of the data I am trying to post. I thought I might resolve this issue by trying to encode the message using uri_escape from the URI::Escape module but that did not appear to resolve the issue. Here is a sample of my code so far.
#!/usr/bin/perl use warnings; use strict; use XML::Smart; use LWP::UserAgent; my $doc = XML::Smart->new(); $doc->{PHC_LOGIN}{USERID} = 'john.doe'; $doc->{PHC_LOGIN}{USERID}->set_node(1); $doc->{PHC_LOGIN}{USERPASSWORD} = 'FAKEPASSWORD'; $doc->{PHC_LOGIN}{USERPASSWORD}->set_node(1); $doc->{PHC_LOGIN}{PARTNERID} = '111'; $doc->{PHC_LOGIN}{PARTNERID}->set_node(1); $doc->save('output.xml'); my $sendXML="output.xml"; my $webpage="https://example.com/Login/AutoLogin.aspx"; my $message=""; open (XML,$sendXML); while (<XML>) { $message .="$_"; } close XML; my $ua = LWP::UserAgent->new; $ua->add_handler("request_send", sub { shift->dump; return }); $ua->add_handler("response_done", sub { shift->dump; return }); $ua->proxy('https', 'http://proxy.example.net:8080/'); my $header= $ua->default_headers; my $response = $ua->post($webpage, Content_Type => 'text/xml', Content + => $message); $response->decoded_content; if ($response->is_success) { my $html = $response->content; if ( $html =~ /\<REDIRECTURL\>(.*)\<\/REDIRECTURL\>/) { my $dest = $1; $ua->post($dest); } else { print "No redirect url found\n"; }; } else { die print $response->status_line; print $response->decoded_content; };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: http url encoding issues.
by argos (Initiate) on Aug 24, 2014 at 18:57 UTC | |
by argos (Initiate) on Aug 24, 2014 at 20:23 UTC | |
|
Re: http url encoding issues.
by Anonymous Monk on Aug 24, 2014 at 22:19 UTC | |
by argos (Initiate) on Aug 25, 2014 at 02:26 UTC | |
by Anonymous Monk on Aug 25, 2014 at 09:32 UTC |