I am going to be writing an application that does a bit of computation on data it gets from a RESTful web service and outputs to a text file and/or HTML page. The web service is XML over HTTP. I have done a simple proof of concept with LWP::Simple and XML::Simple, but it's all a bit ad-hoc.
Can anyone recommend some Perl modules or best practice for interacting with RESTful web services in this way? Is there one module that will take care of all the details for me (making request + handling response) or is the problem domain too general for that?
Note the web service is all XML over HTTP, though I expect to have to use HTTP GET, POST and HEAD eventually. I think I have the option of requesting JSON instead of XML if it makes thins simpler.
Thanks in advance.
These operations stand for four possible actions, known as CRUD: Create, Read, Update and Delete. The server sends the data to the client in one of the following formats: HTML. JSON (which is the most common one thanks to its independence of computer languages and accessibility by humans and machines)
REST stands for Representational State Transfer. It is a software architecture style that relies on a stateless communications protocol, most commonly, HTTP. REST structures data in XML, YAML, or any other format that is machine-readable, but usually JSON is most widely used.
REST is web standards based architecture and uses HTTP Protocol. It revolves around resource where every component is a resource and a resource is accessed by a common interface using HTTP standard methods.
I do most everything either with LWP::Simple, LWP::UserAgent, Mojo::UserAgent or WWW::Mechanize. The REST stuff is just choosing the right URL to send the request too. Once you get the response, there are plenty of modules on CPAN to handle XML or JSON. I particularly like Mojo since it comes with its own JSON and DOM parsers and tools.
REST::Client is nice. Atlassian has a Writing a REST Client in Perl article.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With