2014-06-05 115 views
0

我想翻译下面的curl命令来Rcurl数据和我在使用上面的命令RCURLRcurl与发布使用XML

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中通过数据文件(xml文件)合并-d选项的任何想法?

postForm('http://211.211.211.211:27844/ssentsvc' ,style='HTTPPOST',.opts=list(httpheader=c('SOAPAction'='"http://google.com"', 'Content-Type'='text/xml'),postfields=out2)) 

我试了快速谷歌搜索,找不到任何相关的东西。请告知或指导喵相关的指针。

回答

1

的评论太长......

你可以尝试这样的事情(使用httr包)。

# 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'))) 
+0

可以简化后的呼叫一点:'POST( 'http://211.211.211.211:27844/ssentsvc',身体= upload_file(OUT2),add_headers(的SOAPAction =“HTTP://谷歌。 com“,'Content-Type'='text/xml'))' – hadley