我目前正在为使用Axis2 WS-Security的应用程序开发python WS服务
简化的相关代码为
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和提供WS服务的应用程序的文档,我猜它是在向我请求用户令牌身份验证
<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请求中?
发布于 2011-12-24 05:34:00
查看有关向soapy请求(https://svn.origo.ethz.ch/playmobil/trunk/contrib/pywebsvcs/SOAPpy/docs/UsingHeaders.txt)添加标头的文档。通过这种方式,您可以将自己的自定义标头添加到任何请求。
希望这能有所帮助
https://stackoverflow.com/questions/6301413
复制相似问题