AnsweredAssumed Answered

Calling Web Service with Ruby

Question asked by pjmorce on Jun 3, 2009
Latest reply on Jun 3, 2009 by pjmorce
Hello,

I am new to Alfresco and I am trying it to implement a Web Application using Ruby and Ruby on Rails.

I tried to follow the samples trying to call a web service from my ruby application but I could'nt make it work.

My server is running well. I already inserted some documents. The WSDL of the web service is also accessible. I also installed WSS4 which is needed.

The user/password of my alfresco server is admin/admin.

I tried to call the getStores web service operation and I also tried to query to web service.

Here goes the code of my method wich executes getStores operation:

def getStores
    puts "begin"
   
    user = "admin"
    pwd = "admin"   
    wsdl_url = "http://localhost:8080/alfresco/wsdl/repository-service.wsdl"
    wsdl_url_auth = "http://localhost:8080/alfresco/wsdl/authentication-service.wsdl"
    puts "a"
    soapDriver = SOAP::WSDLDriverFactory.new(wsdl_url_auth).create_rpc_driver()
    puts "b"
    authentication_result = soapDriver.startSession(:username => 'admin', :password => 'admin')
    puts "c"
    ticket = authentication_result.inspect
    puts "1"
    factory = SOAP::WSDLDriverFactory.new(wsdl_url)
    puts "2"
    soap = factory.create_rpc_driver
    puts "3"
    soap.streamhandler.client.receive_timeout = 180
    puts "h"
    resolver = AuthenticateUserResolver.new()
    soapDriver.security().add_security_resolver(resolver)
    soap.security().add_security_token(ticket)
    param=nil
    soapResponse = soap.getStores(param)
    puts "5"
   
    puts "end"
end

The execution of this method returns the following error message: undefined method `process' for #<String:0x49fdfa4>

Here goes the code which executes the query:


def query
    puts "begin…"
 
    begin
      puts "1"
      wsdl_url = "http://localhost:8080/alfresco/wsdl/repository-service.wsdl"
      puts "2"
      soapDriver = SOAP::WSDLDriverFactory.new(wsdl_url).create_rpc_driver()
      puts "3"
      resolver = WSS4R::Tokenresolver::AuthenticateUserResolver.new()
      puts "4"
      soapDriver.security().add_security_resolver(resolver)
      puts "5"
      puts "6"
      soapDriver.security().add_security_token(UsernameToken.new("admin", "admin"))
      puts "7"
      query_result = soapDriver.query(
        {:store => {:scheme => 'company_home', :address => 'SpacesStore'},
        :query => {:language => 'lucene', :statement => 'TEXT:"<brown>"'},
        :includeMetaData => false})
      puts "12"
      puts query_result.to_s
      puts "13"
     
     
    rescue Exception => e
      puts "Error (index): " + e.message
    end
   
    puts "end…"
  end
The executions of this method return the follow error message: Server Error


What am I doing wrong? What am I missing? (my Alfresco server is the version 3.0 - the last one).

Thanks

Regards

Outcomes