Using httr for SOAP API

Hi! For days I've been trying to access EUR-Lex's API (containing EU legal documents) which is built on SOAP. However, I've gotten very confused as to what is needed to solve this task, especially because of the lack of information using R for SOAP.

In short, I believe I have the authentication information and WSDL required to use the SOAP API, but I don't know how to use it.

Hadley Wickham answered a question on Stackoverflow explaining the use of httr for SOAP, which seems very useful:

library(httr)
r <- POST("http://www.sample.com/soap", body = upload_file("request.xml"))
stop_for_status(r)
content(r)

However, my question revolves around the following two points:

First, I don't understand the use of body = upload_file("request.xml") in the POST() function. How does this work? Where does the request.xml come from? Could I use the following link to EUR-Lex's WSDL? And if so, how? https://eur-lex.europa.eu/eurlex-ws?wsdl

Second, how is authentication implemented in the POST() function for SOAP? I believe this would be included in the xml body described above. How can I include authentication in the request.xml object?

It seems that accessing SOAP APIs through R can be done with the RCurl package as well. I'm open to answers using that. One answer on my original question on Stackoverflow used RCurl (see link in post). However, I'd prefer help with httr.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.