开发者

SOAPpy - how to pass a security Header?

开发者 https://www.devze.com 2023-03-12 01:36 出处:网络
Im currently developing a python webservice for an application which uses Axis2 WS-Security the simplified relevant code is

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开发者_StackOverflow.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?


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号