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; };
In reply to http url encoding issues. by argos
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |