pkupnorth has asked for the wisdom of the Perl Monks concerning the following question:
Hello,
I'm trying to consume a web service using Perl. If I use a browser to access the service, the results are returned as formatted XML. This is the response result I'm looking for so that I can subsequently process the results as XML.
I have been able to return results using the LWP::Simple module. However, the results come back in a form that is similar to nested hashes (resembling the compact version of the Dumper module output) see below:
Data Returned:
Here is the code used to retrieve the above data
use LWP::UserAgent; use HTTP::Request::Common qw(GET); my $ua = LWP::UserAgent->new; my $endpoint = 'http://www.SomeBusiness.com:8081/api/CustomerDir/getA +SN'; my $req = HTTP::Request->new('GET'); $req->url($endpoint); my $resp = $ua->request($req); my $message = $resp->content; print "printing message: $message\n\n";
If I just take the $endpoint URL and access it using Firefox, I get formatted XML returned.
I have also tried using SOAP::Lite to access the web service, but SOAP must pass a POST call somewhere in the pre-process set up and this web service won't allow a POST method.
Can someone tell me what I need to add or which module I need to use so that I can do with Perl, programmatically, what my browser does automatically, i.e. it knows to automatically format the returned data as XML or knows that is should not be formatted as nested hashes when returned?
Thanks,
pkupnorth
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Consuming A Web Service
by Corion (Patriarch) on Nov 01, 2016 at 22:10 UTC | |
by pkupnorth (Novice) on Nov 02, 2016 at 16:28 UTC | |
|
Re: Consuming A Web Service
by NetWallah (Canon) on Nov 02, 2016 at 03:18 UTC | |
by pkupnorth (Novice) on Nov 02, 2016 at 16:34 UTC | |
by NetWallah (Canon) on Nov 02, 2016 at 21:38 UTC | |
by pkupnorth (Novice) on Nov 03, 2016 at 15:17 UTC | |
by pryrt (Abbot) on Nov 03, 2016 at 15:47 UTC | |
by NetWallah (Canon) on Nov 03, 2016 at 17:25 UTC | |
| |
|
Re: Consuming A Web Service
by stevieb (Canon) on Nov 01, 2016 at 22:39 UTC | |
by pkupnorth (Novice) on Nov 02, 2016 at 16:52 UTC | |
|
Re: Consuming A Web Service
by glasswalk3r (Friar) on Nov 02, 2016 at 15:59 UTC | |
by pkupnorth (Novice) on Nov 02, 2016 at 16:58 UTC |