500 error when calling webservice through rhosync/rhodes

528 Views Asked by At

I am trying to call a web service in rhosync application.rb, I see a 500 error response in rhosync console .. and 'server returned an error' in BB simulator .. :(

Some info about my setup -

I have created a rhodes app that connects to a rhosync app when user enters user name and password and clicks on "login". I am calling this webservice through "authenticate" method of application.rb of the rhosync application ..

def authenticate(username,password,session)
    Rho::AsyncHttp.get(:url => 'http://mywebserviceURL',:callback => (url_for :action => :httpget_callback),:callback_param => "" )
end

UPDATE

Instead of http:async, I tried consuming a soap based webservice and it worked just fine .. here is code if anyone cones here in search of a sample.. in application.rb of rhosync app

  require "soap/rpc/driver"


        class Application < Rhosync::Base
          class << self
           def authenticate(username,password,session)
              driver = SOAP::RPC::Driver.new('http://webserviceurl')
              driver.add_method('authenticate', 'username', 'password')
              ret=driver.authenticate(username,password)
              if ret=="Success" then
            true
              else
                false
              end
            end
        end

        Application.initializer(ROOT_PATH)
2

There are 2 best solutions below

3
On BEST ANSWER

You can typically find the problem if you crank up your log. Edit rhoconfig.txt in your app set these properties -

# Rhodes runtime properties
MinSeverity  = 1
LogToOutput = 1
LogCategories = *
ExcludeLogCategories =

then try again and watch the terminal output. Feel free to post the log back and I'll take a look. You also might want to echo out puts the mywebserviceURL if you're using that as a variable, I trust you just changed that for the post here. Can you access the webservice if you hit it with a browser?

0
On

require "soap/rpc/driver"

    class Application < Rhosync::Base
      class << self
       def authenticate(username,password,session)
          driver = SOAP::RPC::Driver.new('http://webserviceurl')
          driver.add_method('authenticate', 'username', 'password')
          ret=driver.authenticate(username,password)
          if ret=="Success" then
        true
          else
            false
          end
        end
    end

    Application.initializer(ROOT_PATH)

in this what is done in add_method and authenticate method and where it to be written.