【问题标题】:liferay 6.2GA2 soap authentication with python suds client使用 python suds 客户端进行 liferay 6.2GA2 肥皂身份验证
【发布时间】:2014-05-28 15:30:14
【问题描述】:

liferay 6.2 soap api 有一些问题:我需要它来使用 python suds 客户端搜索用户。

在 liferay 6.1 中,我使用了以下代码,效果很好:

from suds.client import Client
c = Client('http://liferay62instance.domain.com/api/secure/axis/Portal_UserService?wsdl', username='liferayuser', password='liferaypassword')
c.service.getUserByScreenName(companyId=10154, screenName='user')

在liferay 6.2中,wsdl url已经改变,默认不需要http认证,所以使用下面的代码会报错:

from suds.client import Client
c = Client('http://liferay62instance.domain.com/api/axis/Portal_UserService?wsdl', username='liferayuser', password='liferaypassword')
c.service.getUserByScreenName(companyId=10154, screenName='user')

和错误:

Server raised fault: 'java.rmi.RemoteException: Authenticated access required'

使用服务器端回溯:

14:50:45,030 ERROR [ajp-bio-9009-exec-8][UserServiceSoap:845]
java.lang.SecurityException: Authenticated access required
java.lang.SecurityException: Authenticated access required

你知道如何在liferay 6.2中通过soap身份验证吗?

感谢您的任何回答。

杰罗姆。

【问题讨论】:

    标签: python authentication soap liferay suds


    【解决方案1】:

    最后我使用 HttpAuthenticated 传输来自 suds.transport.http

    解决了我的问题

    使用它会添加一个新的标头 Authorization,其中包含用户名 + 密码的 base64 编码组合,并将在每个soap请求中使用。

    这是一个例子:

    from suds.client import Client
    from suds.transport.http import HttpAuthenticated
    
    t = HttpAuthenticated(username='liferayuser', password='liferaypassword')
    c = Client('http://liferay62instance.domain.com/api/axis/Portal_UserService?wsdl', transport=t)
    result = c.service.getUserByScreenName(companyId=10154, screenName='user')
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-08-11
      • 1970-01-01
      • 2014-10-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-10
      • 1970-01-01
      相关资源
      最近更新 更多