SOAPpy - 如何传递安全标头?
我目前正在为使用 Axis2 WS-Security 的应用程序开发一个 python Web 服务,
简化的相关代码是
from SOAPpy import SOAPProxy
from SOAPpy import WSDL
file = 'path/to/my/file?wsdl'
server = WSDL.Proxy(file)
server.foo(bar)
在执行此操作时我得到的:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\SOAPpy\Client.py", line 471, in __call__
return self.__r_call(*args, **kw)
File "C:\Python27\lib\site-packages\SOAPpy\Client.py", line 493, in __r_call
self.__hd, self.__ma)
File "C:\Python27\lib\site-packages\SOAPpy\Client.py", line 407, in __call
raise p
SOAPpy.Types.faultType: <Fault soapenv:Client: WSDoAllReceiver: Incoming message
does not contain required Security header: >
阅读 axis2 WS-security 的文档和提供 Web 服务的应用程序我猜它要求我提供用户令牌类似于
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" soapenv:mustUnderstand="1">
<wsu:Timestamp xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="Timestamp-12468716">
<wsu:Created>
2008-06-23T13:17:13.841Z
</wsu:Created>
<wsu:Expires>
2008-06-23T13:22:13.841Z
</wsu:Expires>
</wsu:Timestamp>
<wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="UsernameToken-31571602">
<wsse:Username>
alice
</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">
bobPW
</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
执行请求时的身份验证,所以问:如何将其附加到 SOAPpy 请求中?
Im currently developing a python webservice for an application which uses Axis2 WS-Security
the simplified relevant code is
from SOAPpy import SOAPProxy
from SOAPpy import WSDL
file = 'path/to/my/file?wsdl'
server = WSDL.Proxy(file)
server.foo(bar)
when doing this i get:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\SOAPpy\Client.py", line 471, in __call__
return self.__r_call(*args, **kw)
File "C:\Python27\lib\site-packages\SOAPpy\Client.py", line 493, in __r_call
self.__hd, self.__ma)
File "C:\Python27\lib\site-packages\SOAPpy\Client.py", line 407, in __call
raise p
SOAPpy.Types.faultType: <Fault soapenv:Client: WSDoAllReceiver: Incoming message
does not contain required Security header: >
Reading the doc for the axis2 WS-security and the app providing the webservices im guessing its asking me for a user token authentication in the likes of
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" soapenv:mustUnderstand="1">
<wsu:Timestamp xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="Timestamp-12468716">
<wsu:Created>
2008-06-23T13:17:13.841Z
</wsu:Created>
<wsu:Expires>
2008-06-23T13:22:13.841Z
</wsu:Expires>
</wsu:Timestamp>
<wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="UsernameToken-31571602">
<wsse:Username>
alice
</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">
bobPW
</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
when doing a request, so Q: how can I append this to the SOAPpy request?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看有关向肥皂请求添加标头的文档 (https://svn.origo.ethz.ch/playmobil/trunk/contrib/pywebsvcs/SOAPpy/docs/UsingHeaders.txt)。这样您就可以将自己的自定义标头添加到任何请求中。
希望这有帮助
Check out the documentation on adding headers to a soapy request (https://svn.origo.ethz.ch/playmobil/trunk/contrib/pywebsvcs/SOAPpy/docs/UsingHeaders.txt). This way you can add your own custom headers to any request.
Hope this helps