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?
- EUR-Lex WSDL: https://eur-lex.europa.eu/eurlex-ws?wsdl
- EUR-Lex API guide: https://eur-lex.europa.eu/content/tools/webservices/SearchWebServiceUserManual_v2.00.pdf
- Hadley's answer on Stackoverflow: https://stackoverflow.com/questions/27410580/how-to-convert-soap-request-curl-to-rcurl?noredirect=1&lq=1
- My original question on Stackoverflow: https://stackoverflow.com/questions/62668337/how-to-do-a-soap-request-for-eur-lex-api-with-r