ruby中如何调用webservice

上一篇 / 下一篇  2013-02-24 10:41:20 / 个人分类:脚本开发

由于工作需要,最近在学习webservice相关的东西

下面就说下在ruby下怎么调用webservice

  1. require 'soap/wsdlDriver'  
  2. def project  
  3.     @URL = 'http://192.168.1.5:7001/bpm?WSDL';  
  4.     soap_client =   
  5.     SOAP::WSDLDriverFactory.new(@URL).create_rpc_driver  
  6.     @result = soap_client.startSession("eric","eric");  
  7. end  

 

首先包含 require 'soap/wsdlDriver'

@URL是wsdl地址, 通过这个地址你可以访问到webservice对外公布的接口。

其次通过

soap_client = SOAP::WSDLDriverFactory.new(@URL).create_rpc_driver获得该webservice的实体。。。说简单点就是你期望调用的远程对象

soap_client.startSession("eric","eric");

这就调用了webservice中定义的一个方法

startSession(String user, String password)是对外公开一个方法

webservice对外公开的方法都可以在wsdl中找到


TAG:

 

评分:0

我来说两句

Open Toolbar