Ruby调用wsdl的中文化完美解决方案

Webservices的中文化完美解决方案

Ruby调用wsdl的中文化完美解决方案_第1张图片

require 'soap/wsdlDriver'

require 'iconv'

##UTF8_TO_GBK = Iconv.new "GBK","UFT8"

url = "http://40.1.41.52/MonitorSer/Service.asmx?wsdl"

drv = SOAP::WSDLDriverFactory.new(url).create_rpc_driver

##将短信内容写入数据库

XSD::Charset.encoding='UTF8'

my_param={:txtMessage=>Iconv.conv('utf-8', 'gbk',"测试成功")}

result=drv.AddtoDatabase(my_param)

##result2 =drv.send("HelloWorld",my_param)

puts result["AddtoDatabaseResult"]

##开始测试传送短信

my_param2={:Mobile=>"13509390212",:txtMessage=>"hello world"}

XSD::Charset.encoding='UTF8'

result2=drv.PostMobileMessage(my_param2)

puts result2["PostMobileMessageResult"]

##测试发送电子邮件`

my_param3={:MailAddress=>"[email protected]",:MailSubject=>"my test",:MailContent=>"my first mail"}

result3=drv.PostMail(my_param3)

puts result3["PostMailResult"]

你可能感兴趣的:(Ruby)