R中的SOAP请求-内容长度=0

R中的SOAP请求-内容长度=0,r,xml,soap,rcurl,R,Xml,Soap,Rcurl,有人能告诉我在R中使用这个SOAP请求的目的地吗?使用Python发送请求时,我可以从服务器获得有效的响应,但在R中,我在响应中得到一个空的正文(Content length=0) 以下是请求示例: 以及示例响应: 库(RCurl) 头字段= c(Accept=“text/xml”, “内容类型”=“文本/xml;字符集=utf-8”, SOAPAction=“”) 血栓素B体 http://www.ogc.org/SOS http://www.opengis.net/def/serviceOp

有人能告诉我在R中使用这个SOAP请求的目的地吗?使用Python发送请求时,我可以从服务器获得有效的响应,但在R中,我在响应中得到一个空的正文(Content length=0)

以下是请求示例:

以及示例响应:

库(RCurl)
头字段=
c(Accept=“text/xml”,
“内容类型”=“文本/xml;字符集=utf-8”,
SOAPAction=“”)
血栓素B体
http://www.ogc.org/SOS
http://www.opengis.net/def/serviceOperation/sos/core/2.0/GetCapabilities
http://www.w3.org/2005/08/addressing/anonymous
0
'
h=basicTextGatherer()

R我找到了一个解决办法,在发送到curlPerform
TXbody之前,从TXbody中删除换行符和空格。我找到了一个解决办法,在发送到curlPerform
TXbody之前,从TXbody中删除换行符和空格
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()