R中的SOAP请求
Posted
技术标签:
【中文标题】R中的SOAP请求【英文标题】:SOAP request in R 【发布时间】:2014-11-03 15:45:16 【问题描述】:有人知道如何用 R 制定以下 SOAP 请求吗?
POST /API/v201010/AdvertiserService.asmx HTTP/1.1
Host: advertising.criteo.com
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "https://advertising.criteo.com/API/v201010/clientLogin"
<?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:Body>
<clientLogin xmlns="https://advertising.criteo.com/API/v201010">
<username>string</username>
<password>string</password>
<source>string</source>
</clientLogin>
</soap:Body>
</soap:Envelope>
【问题讨论】:
你目前的努力取得了什么成果? 谢谢@Thomas。我在documentation of the RCurl package找到了解决方案。 太棒了。请记住通过单击答案左侧的复选框将您的答案标记为已接受,以便其他人可以看到您的问题已得到解决。 【参考方案1】:这样就解决了问题:
library(RCurl)
headerFields =
c(Accept = "text/xml",
Accept = "multipart/*",
'Content-Type' = "text/xml; charset=utf-8",
SOAPAction = "https://advertising.criteo.com/API/v201010/clientLogin")
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:Body>
<clientLogin xmlns="https://advertising.criteo.com/API/v201010">
<username>string</username>
<password>string</password>
<source>string</source>
</clientLogin>
</soap:Body>
</soap:Envelope>'
curlPerform(url = "https://advertising.criteo.com/API/v201010/AdvertiserService.asmx",
httpheader = headerFields,
postfields = body
)
【讨论】:
如果您需要包含 SSL 证书和密码,这会怎样?以上是关于R中的SOAP请求的主要内容,如果未能解决你的问题,请参考以下文章