如何将使用curl
发送的POST请求转换为等效的RCurl命令?
curl 'http://www.example.com/example' -H 'Origin: http://www.example.com' -H 'Content-Type: text/xml;charset=utf-8' --data-binary '<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Header><clsSoapHeader xmlns="http://www.example.com/example"></clsSoapHeader></soap:Header><soap:Body><example-tag></example-tag></soap:Body></soap:Envelope>'
答案 0 :(得分:1)
基于@Thomas的建议,这是我找到的解决方案
h <- basicTextGatherer()
url <- 'http://www.example.com/example'
body <- '<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Header><clsSoapHeader xmlns="http://www.example.com/example"></clsSoapHeader></soap:Header><soap:Body><example-tag></example-tag></soap:Body></soap:Envelope>'
curlPerform(url = url, httpheader=c(Accept="text/xml", Accept="multipart/*", 'Content-Type' = "text/xml; charset=utf-8"), postfields=body, writefunction = h$update, verbose = TRUE)
然后,可以通过h$update()