本文介绍了Rcurl与使用xml发布数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正试图将以下curl命令翻译为Rcurl,并且在使用RCURL使用文件发布数据时遇到问题
I am trying to translate following curl command to Rcurl and am having trouble in posting the data using a file using RCURL
curl –X POST –d @out2 http://211.211.211.211:27844/ssentsvc -- header 'SOAPAction: "http://google.com"' --header 'Content-Type: text/xml'
以上命令工作
RCURL,关于如何在R curl中合并-d选项以通过数据文件(xml文件)发布的任何想法
I am trying the following in RCURL, any ideas on how to incorporate -d option in R curl for posting via a data file(xml file) ??
postForm('http://211.211.211.211:27844/ssentsvc' ,style='HTTPPOST',.opts=list(httpheader=c('SOAPAction'='"http://google.com"', 'Content-Type'='text/xml'),postfields=out2))
和没有找到任何相关。
I tried a quick google search and could not find anything relevent. Please advise or direct mew to relevant pointers.
推荐答案
太长时间无法发表评论...
Too long for a comment...
您可以尝试这样(使用 httr
包)。
You could try something like this (using the httr
package).
# this is just to create a file with xml content - you have this already
library(XML)
txt <- '<?xml version="1.0" encoding="UTF-8"?><doc><item>text</item><item>text</item><item>text</item></doc>'
out2 <- "myfile.xml"
saveXML(xmlTreeParse(txt,useInternalNodes=T),out2)
# you start here...
library(httr)
POST(url='http://211.211.211.211:27844/ssentsvc',
body=upload_file(out2),
config=add_headers(c('SOAPAction'='"http://google.com"', 'Content-Type'='text/xml')))
这篇关于Rcurl与使用xml发布数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!