savon调用WebService服务

查询手机号归属地
wsdl: http://ws.webxml.com.cn/WebServices/MobileCodeWS.asmx?WSDL

require 'savon'
client = Savon.client(
 wsdl:'http://ws.webxml.com.cn/WebServices/MobileCodeWS.asmx?WSDL'
)
puts client.methods
puts client.operations #查看可操作方法 
#[:get_mobile_code_info, :get_database_info]

#调用get_database_info方法,该方法可以获得国内手机号码归属地数据库信息。
输入参数:无;
返回数据:一维字符串数组(省份 城市 记录数量)
client.call(:get_database_info).body


获得国内手机号码归属地省份、地区和手机卡类型信息。
输入参数:mobileCode = 字符串(手机号码,最少前7位数字),userID = 字符串(商业用户ID)免费用户为空字符串;
返回数据:字符串(手机号码:省份 城市 手机卡类型)
res = client.call(:get_mobile_code_info) do 
  message mobileCode:'xxxxx'
end

#OR

res = client.call(:get_mobile_code_info,:message=>{:mobileCode=>"xxxx"})

puts res.body
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章