1

Can someone wise point out to me where i am going wring with this SOAP request in R? I can get a valid response from the server when sending request with Python but in R i get an empty body in the response (Content-length = 0).

Here is the example request: http://www.bom.gov.au/waterdata/wiski-web-public/GetCapabilities%20example%20request.xml

and the example response: http://www.bom.gov.au/waterdata/wiski-web-public/GetCapabilities%20example%20response.xml

library(RCurl)

headerFields = 
  c(Accept = "text/xml",
    'Content-Type' = "text/xml; charset=utf-8",
    SOAPAction = "")

TXbody = '<?xml version="1.0" encoding="UTF-8"?>
<soap12:Envelope xmlns:soap12="http://www.w3.org/2003/05/soap-envelope" xmlns:sos="http://www.opengis.net/sos/2.0" xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:fes="http://www.opengis.net/fes/2.0" xmlns:gml="http://www.opengis.net/gml/3.2" xmlns:swes="http://www.opengis.net/swes/2.0" xsi:schemaLocation="http://www.w3.org/2003/05/soap-envelope http://www.w3.org/2003/05/soap-envelope/soap-envelope.xsd http://www.opengis.net/sos/2.0 http://schemas.opengis.net/sos/2.0/sos.xsd">
<soap12:Header>
<wsa:To>http://www.ogc.org/SOS</wsa:To>
<wsa:Action>
http://www.opengis.net/def/serviceOperation/sos/core/2.0/GetCapabilities
</wsa:Action>
<wsa:ReplyTo>
<wsa:Address>http://www.w3.org/2005/08/addressing/anonymous</wsa:Address>
</wsa:ReplyTo>
<wsa:MessageID>0</wsa:MessageID>
</soap12:Header>
<soap12:Body>
<sos:GetCapabilities service="SOS"/>
</soap12:Body>
</soap12:Envelope>'

h = basicTextGatherer()
R <- curlPerform(url = "http://www.bom.gov.au/waterdata/services?service=SOS",
                 httpheader = headerFields,
                 postfields = TXbody, verbose=TRUE,
                 writefunction = h$update)
RXbody <- h$value()

The response i get is:

  • Trying 104.99.8.39...
  • Connected to www.bom.gov.au (104.99.8.39) port 80 (#0)

    POST /waterdata/services?service=SOS HTTP/1.1 Host: www.bom.gov.au Accept: text/xml Content-Type: text/xml; charset=utf-8 Content-Length: 1018

  • upload completely sent off: 1018 out of 1018 bytes < HTTP/1.1 200 OK < Access-Control-Allow-Origin: * < Content-Type: text/plain; charset=UTF-8 < Server: Apache-Coyote/1.1 < X-UA-Compatible: IE=Edge < Content-Length: 0 < Expires: Tue, 12 Mar 2019 08:11:53 GMT < Cache-Control: max-age=0, no-cache, no-store < Pragma: no-cache < Date: Tue, 12 Mar 2019 08:11:53 GMT < Connection: keep-alive <

  • Connection #0 to host www.bom.gov.au left intact

I have tried this: SOAP request in R and this: SOAP request failure in R

Jordan
  • 173
  • 1
  • 2
  • 9
  • I've found a workaround by removing linebreaks and spaces from the TXbody before sending it to curlPerform `TXbody <- gsub("[\r\n]", "", TXbody)` – Jordan Mar 13 '19 at 03:45

0 Answers0