B-cycle ページ (www.bcycle.com/whowantsitmore.aspx) で、投票の場所と値を収集しようとしています。
URL http://mapservices.bcycle.com/bcycleservice.asmxは SOAP サービスです。
ドキュメントに基づいて、私はそれを正しく行っていると信じていますが、入力パラメーターの解析によりエラーが発生します。パラメータなしで関数を呼び出しても、エラーが発生します。
# 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"
これは、関数内の次のコードによるものです。
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="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
この R に焦点を当て続けることに本当に興味がありますが、Python を使用すると、問題が何であるかをより簡単に把握できる場合があります。
何か案は?