Send XML to a Perl script

I am trying to write a RESTful web service in Perl.

I have a perl script that can read in XML using XML::Simple which is sitting at a particular URL. I want to send XML to that script from another thing (be it a web page, application etc.).

What I don't know is how I'd go about getting the Perl to realise XML was being sent to it and load that XML into XML::Simple (or any other XML module if another is more relevant).

Thanks for any help
intechfsAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ozoCommented:
are you trying to do this by modifying the code in the script, or by invoking the script in a particular way?
in either case it may help to see how the script is now realizing its input.
0
intechfsAuthor Commented:
The XML is sent from something, like say a PHP script which calls the Perl at a particular URL.

I don't want to have to attach it as a GET variable or POST if it can be avoided.

I haven't written the Perl that reads in the XML yet, but when I do I will probably be using XML::Simple to do so.
0
Adam314Commented:
If the script is being called as a URL, it is likely getting it's data the same way a GET or POST request would.  If so, you can use the CGI module to handle getting the data.  Something like this:
########## To display all parameters
#!/usr/bin/perl
use strict;
use CGI ':standard';
 
print header('text/plain');
foreach (param()) {
    print "$_ = " . join(", ", param($_)) . "\n";
}
 
########## To get one, and use it with XML::Simple
#!/usr/bin/perl
use strict;
use CGI ':standard';
use XML::Simple;
 
my $XMLstring = param('XML');
my $xml = XMLin($XMLstring);
#Now, $xml is a reference to your xml data

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
intechfsAuthor Commented:
Thanks for this, works great.
0
jbmrajaCommented:
I wanna know how can i send an XML to a perl web service from a php page? So many of the articles in the web shows that a request must be a HTTP GET/POST only. If it so then how can i send an XML as a input to a perl web service?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Services

From novice to tech pro — start learning today.