Hello again Quasi-Divine Monk,
Once again I need to call upon your vast knowledge in my question to better understand all things perl.
The code below works if I replace the variable $Token with the actual token generated from the first cURL statement but if I use the code shown below it does not (IE instead of the actual token using $Token). I've tried enclosing the variable in single and double quotes, single+double quotes and vice versa, and sigle+double+singe quotes and double+single+double quotes. Nothing works. It spits out the XML shown below the code snippet in all instances. The 2nd cURL statement is where I believe the problem lies (this is the cURL statement using the token generated in the first cURL statement).
#!/usr/bin/perl
use XML::Simple;
use Data::Dumper;
use strict;
use warnings;
my $HOST1='https://ws.fluffybunnies.com/zyxws/zyxws';
my $HOST2='https://ws.fluffybunnies.com/xyzws/xyzws';
my $ADMIN_UID='rabbit.lover@rabbits.com';
my $ADMIN_PASS= $ARGV[0];
my $Token='';
my $Title='';
$Token = `curl --insecure -Ss -d '<?xml version="1.0" ?><S:Envelope xm
+lns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><ns5:getTok
+en xmlns:ns2="java:com.tl.zyxws" xmlns:ns3="java:language_builtins.la
+ng" xmlns:ns4="java:com.tl.zyxws.parameters" xmlns:ns5="http://ws.flu
+ffybunnies.com:80/zyxws"><ns4:password>'$ADMIN_PASS'</ns4:password><n
+s4:uid>'$ADMIN_UID'</ns4:uid></ns5:getToken></S:Body></S:Envelope>' -
+-header "Content-Type: text/xml; charset=utf-8" $HOST1 | egrep -o '[A
+-Z0-9]{32,}'`;
print "Token: ".$Token."\n";
$Title = `curl --insecure -Ss -d '<?xml version="1.0" ?><S:Envelope xm
+lns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><ns5:getTit
+le xmlns:ns2="java:com.tl.xyzws" xmlns:ns3="java:language_builtins.la
+ng" xmlns:ns4="java:com.tl.xyzws.parameters" xmlns:ns5="http://ws.flu
+ffybunnies.com:80/xyzws"><ns4:isbn>123456789</ns4:isbn><ns4:epi>12121
+212121212121212</ns4:epi><ns4:token>'$Token'</ns4:token></ns5:getTitl
+e></S:Body></S:Envelope>' --header "Content-Type: text/xml; charset=u
+tf-8" $HOST2`;
my $xml = new XML::Simple;
my $data = $xml->XMLin($Title);
The output throws no errors but the Dumper spits out the following. I'll add that I could not find a good way to display this /w the wrapping so I shortened (the output does not look like this exactly, white space was removed).
$VAR1 = {
'soap:Body' => {
'ns5:getTitleResponse' => {
'xsi:nil' => 'true',
'xmlns:ns4' => 'java:language_builtins.lang',
'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
'xmlns:ns3' => 'java:com.tl.xyzws.parameters',
'xmlns:ns5' => 'http://ws.fluffybunnies.com:80/olrws',
'xmlns:ns2' => 'java:com.tl.xyzws'
}
},
'xmlns:soap' => 'http://schemas.xmlsoap.org/soap/envelope/'
};
With the actual token instead of the above I get the expected XML (title info, ect). It's wonderful except I don't want to have to manually paste in the title when this script is run since ideally I'll be using this in an automated process.
Thank you again for any help you can provide and I'll add that I'm in a bash shell on Unix(Debian).
Kevin M
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.