Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SOAP request in R

Tags:

soap

r

rcurl

httr

Does anyone know how to formulate following SOAP request with 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>
like image 909
jburkhardt Avatar asked Nov 03 '14 15:11

jburkhardt


People also ask

Is SOAP request GET or POST?

SOAP Example QAComplete SOAP requests are HTTP POST requests made to the web service endpoint URL. The client and server exchange data in the XML format in the body of HTTP requests and responses.

Does SOAP have GET request?

I always used POST but according to the W3C standard, SOAP supports both POST and GET methods. Edit: After some research, it seems that it's not completely true, as you can see here. It is theoretically possible to use GET because POST and GET are methods of HTTP transport protocol and SOAP can be used over HTTP.

What is a SOAP request?

What is SOAP. SOAP is the Simple Object Access Protocol, a messaging standard defined by the World Wide Web Consortium and its member editors. SOAP uses an XML data format to declare its request and response messages, relying on XML Schema and other technologies to enforce the structure of its payloads.


1 Answers

This solves the problem:

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
                          )
like image 164
jburkhardt Avatar answered Sep 18 '22 19:09

jburkhardt