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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章