I have a SOAP request that is getting a correct response in Rstudio as shown in the screenshot below. The code used to request the response is
library(RCurl)
headerFields =
c(Accept = "text/xml",
'Content-Type' = "text/xml; charset=utf-8",
SOAPAction = "")
body = '<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sch="http://www.xxxxx.com/esotservice/schema">
<S:Header/>
<S:Body>
<sch:OwnerOnlyInquiryRequest>
<sch:RequestHeader>
<sch:ClientSystem>ePRS</sch:ClientSystem>
</sch:RequestHeader>
<sch:RequestParameterList>
<sch:RequestParam>12174391</sch:RequestParam>
</sch:RequestParameterList>
<sch:RequestType>CESEID</sch:RequestType>
<sch:PeckingOrder>Pricing</sch:PeckingOrder>
<sch:ViewType>Pricing</sch:ViewType>
</sch:OwnerOnlyInquiryRequest>
</S:Body>
</S:Envelope>'
R <- curlPerform(url = "http://slsesotdevt1.ute.xxxx.com:10149/esot/esotservice.wsdl",
httpheader = headerFields,
postfields = body, verbose=TRUE)
The response I am getting in RStudio is
My intention is to store the webservice response (black text from the image) into object called R in the code with the object class as XML so that I can use XML package to further process the data. However, when I say print(R) the only response I get is
After searching the web the response 0 indicates that all went correctly. But is there a way to actually store the response in R? If I copy paste the black text appearing in the first image in Rstudio and feed it to xml functions such xmlTreeParse, it gets processed correctly.
You need to fetch the response body using a basicTextGatherer.
For example (taken from https://cran.r-project.org/web/packages/RCurl/RCurl.pdf):
library(RCurl)
headerFields =
c(Accept = "text/xml",
'Content-Type' = "text/xml; charset=utf-8",
SOAPAction = "")
body = '<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sch="http://www.xxxxx.com/esotservice/schema">
<S:Header/>
<S:Body>
<sch:OwnerOnlyInquiryRequest>
<sch:RequestHeader>
<sch:ClientSystem>ePRS</sch:ClientSystem>
</sch:RequestHeader>
<sch:RequestParameterList>
<sch:RequestParam>12174391</sch:RequestParam>
</sch:RequestParameterList>
<sch:RequestType>CESEID</sch:RequestType>
<sch:PeckingOrder>Pricing</sch:PeckingOrder>
<sch:ViewType>Pricing</sch:ViewType>
</sch:OwnerOnlyInquiryRequest>
</S:Body>
</S:Envelope>'
h = basicTextGatherer()
R <- curlPerform(url = "http://slsesotdevt1.ute.xxxx.com:10149/esot/esotservice.wsdl",
httpheader = headerFields,
postfields = body, verbose=TRUE,
writefunction = h$update)
body <- h$value()