4

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

user1766682
  • 400
  • 3
  • 14
  • Have you looked into the `SSOAP` package? – jlhoward Dec 10 '14 at 21:01
  • possible duplicate of [SOAP request in R](http://stackoverflow.com/questions/26717706/soap-request-in-r) – jdharrison Dec 10 '14 at 21:08
  • Yes, I tried with SSOAP but it is throwing an "recursive error" at interface function which I do not understand and can not trace. No hints in the net available as well. So, now I am asking for a help to assemble the post request by hand with RCurl – user1766682 Dec 10 '14 at 21:25

1 Answers1

15

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)
hadley
  • 102,019
  • 32
  • 183
  • 245