通过 rhosync/rhodes 调用 webservice 时出现 500 错误
我正在尝试在 rhosync application.rb 中调用 Web 服务,我在 rhosync 控制台中看到 500 错误响应..并且在 BB 模拟器中看到“服务器返回错误”.. :(
有关我的设置的一些信息 -
我创建了一个 rhodes当用户输入用户名和密码并单击“登录”时连接到 rhosync 应用程序的应用程序我通过 rhosync 应用程序的 application.rb 的“authenticate”方法调用此网络服务..
def authenticate(username,password,session)
Rho::AsyncHttp.get(:url => 'http://mywebserviceURL',:callback => (url_for :action => :httpget_callback),:callback_param => "" )
end
更新
相反。 http:async,我尝试使用基于肥皂的网络服务,它工作得很好..如果有人在这里寻找示例,这里是代码..在 rhosync 应用程序的 application.rb 中
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)
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)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您启动日志,通常可以找到问题。在您的应用程序中编辑 rhoconfig.txt
设置这些属性 -
然后重试并观察终端输出。请随时将日志发回来,我会看一下。
如果您将 mywebserviceURL 用作变量,您可能还想回显 put mywebserviceURL,我相信您刚刚在此处更改了该帖子。如果用浏览器访问网络服务可以访问吗?
You can typically find the problem if you crank up your log. Edit rhoconfig.txt in your app
set these properties -
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?
需要“soap/rpc/driver”
在add_method和authenticate方法中完成的操作及其写入位置。
require "soap/rpc/driver"
in this what is done in add_method and authenticate method and where it to be written.