2014-11-03 2 views
7

Кто-нибудь знает, как сформулировать следующий запрос SOAP с помощью R?Запрос SOAP в R

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> 
+1

Что ваши нынешние усилия до сих пор получить? – Thomas

+0

Спасибо @Thomas. Я нашел решение в [документации пакета RCurl] (http://www.omegahat.org/RCurl/RCurlJSS.pdf). – jburkhardt

+0

Отлично. Не забывайте отмечать свой ответ как принятый, установив флажок слева от ответа, чтобы другие могли видеть, что ваша проблема решена. – Thomas

ответ

8

Это решает проблему:

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 
         )