在B周期页面(www.bcycle.com/whowantsitmore.aspx)我试图刮取票数的位置和值。使用R SOAP(SSOAP)检索数据/刮
URL http://mapservices.bcycle.com/bcycleservice.asmx是一个SOAP服务。
基于documentation我相信我正确地做了,但由于解析输入参数,我得到一个错误。即使调用没有参数的函数也会产生错误。
# working with SOAP
#install.packages("SSOAP", repos="http://www.omegahat.org/R", dependencies = T, type = "source")
library(SSOAP)
# Process the Web Service Definition Language (WSDL) file
bcycle.asmx <- processWSDL("http://mapservices.bcycle.com/bcycleservice.asmx?WSDL")
# Generate functions based on definitions to access the different data sets
bcycle.interface <- genSOAPClientInterface([email protected][[1]], def = bcycle.asmx, [email protected], verbose=T)
# Get the data by requesting the number of cities, username and password (yes it is public)
[email protected]$getCities("10","bcycle","[email protected]")
# receive error: Error in as(parameters, "limit.userName.pw") :
# no method or default for coercing "character" to "limit.userName.pw"
这是由于在功能如下代码:
function(parameters = list(...),... etc) {
...
as(parameters, "limit.userName.pw")
...
}
因此我试图用直接.soap扩展功能:
# Using RCurl library
library(RCurl)
# set up curl options
curl.opts <- curlOptions(
verbose=T,
header=T,
cookie="ASP.NET_SessionId=dv25ws551nquoezqwq3iu545;__utma=27517231.373920809.1357910914.1357910914.1357912862.2;__utmc=27517231;__utmz=27517231.1357910914.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none);__utmb=27517231.13.10.1357912862",
httpheader = c('Content-Type' = 'text/xml; charset=utf-8', Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"),
followLocation = TRUE,
useragent = "Mozilla/5.0 (Windows NT 6.1; rv:18.0) Gecko/20100101 Firefox/18.0")
# Define header and submit request
bcycle.server <- SOAPServer("http://mapservices.bcycle.com/bcycleservice.asmx")
.SOAP(bcycle.server,
"getCities",
limit=250,userName="bCycle",pw="[email protected]",
action="http://bcycle.com/getCities",
xmlns="http://bcycle.com/",
.opts=curl.opts,
.literal=T,
nameSpaces = "1.2",
elementFormQualified = T,
.returnNodeName = 'getCitiesResponse',
.soapHeader = NULL)
我管理连接到他们的服务器但收到错误:
System.Web.Services.Protocols.SoapException:
Server did not recognize the value of HTTP Header SOAPAction:
http://bcycle.com/getCities#getCities
这些是我尝试过的没有成功的选项。
使用Python我能够提出getCities请求,但没有收到任何回应。
3210我在保持该R集中,但使用Python可以提供更容易洞察问题可能是真正感兴趣。
任何想法?
的http://mapservices.bcycle.com/bcycleservice.asmx?WSDL工作服务似乎不可用。 –