Welcom ,I hope yo will enjoy here!

Ruby以SOAP协议访问Webservice

1. 测试qq是否在线

require "soap/wsdlDriver"

def get_qq_satus(qqcode)
  wsdl = "http://www.webxml.com.cn/webservices/qqOnlineWebService.asmx?wsdl"
  driver = SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver
  driver.wiredump_file_base = 'log_file'#记录在使用WebService接口时所有发出和收到的xml消息
  ret = driver.qqCheckOnline(:qqCode=>qqcode)#访问webservice的函数
  p ret
  p ret.qqCheckOnlineResult
  if ret.qqCheckOnlineResult == “Y”
    puts "#{qqcode} 用户在线"
  else
    puts "#{qqcode} 不用户在线"
  end
end

qqcode = "XXXXXXXX"
get_qq_satus(qqcode)

posted on 2012-05-24 19:40  北国的雨  阅读(766)  评论(0编辑  收藏  举报

导航