在B循环页面上(www.bcycle.com/whowantsitmore.aspx)我在努力收集选票的位置和价值。在
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(bcycle.asmx@operations[[1]], def = bcycle.asmx, bcycle.asmx@name, verbose=T)
# Get the data by requesting the number of cities, username and password (yes it is public)
bcycle.interface@functions$getCities("10","bcycle","c@rbont0ns")
# receive error: Error in as(parameters, "limit.userName.pw") :
# no method or default for coercing "character" to "limit.userName.pw"
这是由于函数中的以下代码造成的:
^{pr2}$因此,我尝试直接使用.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="c@rbont0ns",
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发出请求,但是没有收到任何回复。在
import suds
client = suds.client.Client('http://mapservices.bcycle.com/bcycleservice.asmx?WSDL')
print client # prints WSDL info
print client.service.getCities(10,'bcycle','c@rbont0ns') #prints nothing
但我可能会更关注python的问题。在
有什么想法吗?在
请尝试更正用户名并显式命名参数:
Python调用也将使用正确的用户名
^{pr2}$相关问题 更多 >
编程相关推荐