Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert SOAP request curl to RCurl

Tags:

curl

r

rcurl

How should I convert this one liner:

curl -d @request.xml -o response.xml http://www.sample.com/soap

It is accessing request xml which looks like this:

<?xml version="1.0" encoding="utf-8"?>
     <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http://sample.com/">
    <soap:Body>
      <req:getEvents>
        <start>2014-12-12T00:00:00+0100</start>
        <end>2014-12-13T00:00:00+0100</end>
        <type>TYPE</type>
      </req:getEvents>
     </soap:Body>
    </soap:Envelope>

The response is written into response.xml I would like to read the response directly into r

like image 849
user1766682 Avatar asked Dec 06 '22 23:12

user1766682


1 Answers

Here's how with httr:

library(httr)
r <- POST("http://www.sample.com/soap", body = upload_file("request.xml"))
stop_for_status(r)
content(r)
like image 144
hadley Avatar answered Dec 28 '22 02:12

hadley