To make an httr SOAP API request using R, follow these steps:
httr
and XML
packages in R by using the following commands in R console:install.packages("httr")
install.packages("XML")
httr
and XML
packages in R.library(httr)
library(XML)
url <- "http://example.com/soap-api"
soap_body <- '<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<myFunctionRequest xmlns="http://example.com/">
<parameter1>value1</parameter1>
<parameter2>value2</parameter2>
</myFunctionRequest>
</soap:Body>
</soap:Envelope>'
Note: Replace the myFunctionRequest
and parameter1
, parameter2
with your desired function and parameters.
httr
package.response <- POST(url,
body = soap_body,
add_headers("Content-Type" = "text/xml;charset=UTF-8",
"SOAPAction" = "http://example.com/myFunction"),
verbose())
Note: Replace the "http://example.com/myFunction"
with your desired function.
response_content <- content(response, as = "text")
response_xml <- xmlParse(response_content)
result <- xpathApply(response_xml, "//myResult", xmlValue)
Note: Replace "//myResult"
with your desired result node.
print(result)
Your output will contain the required information from the SOAP API request.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2021-06-11 11:00:00 +0000
Seen: 20 times
Last updated: Jul 30 '21
What does the "429 error" in the request response of Instabot mean?
Can migration files be executed in knex upon making an API request?
What is the process of performing a GET request while using OAuth1 authentication?
What does it mean when API Gateway gives a 503 Service Unavailable error?
How can Google OAuth be integrated with FastAPI?
How can Azure DevOps Pull Request and Jenkins be utilized within a corporate network?
Is it possible for someone to make FieldOutputRequestState functional in Abaqus Scripting?
What is the way to hold off until Flask handles all requests?
How can type hinting be implemented in JSDoc for the request body of an express js application?