Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/286.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python SOAPpy-如何传递安全标头?_Python_Web Services_Axis2_Webservice Client_Soappy - Fatal编程技术网

Python SOAPpy-如何传递安全标头?

Python SOAPpy-如何传递安全标头?,python,web-services,axis2,webservice-client,soappy,Python,Web Services,Axis2,Webservice Client,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&

我目前正在为使用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: >
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
文件“C:\Python27\lib\site packages\SOAPpy\Client.py”,第471行,在调用中__
返回自。\ r\u调用(*参数,**千瓦)
文件“C:\Python27\lib\site packages\SOAPpy\Client.py”,第493行,在\uu\r\u调用中
self.\uuuhd,self.\uma)
文件“C:\Python27\lib\site packages\SOAPpy\Client.py”,第407行,在调用中
提高p
SOAPpy.Types.faultType:
正在阅读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>

2008-06-23T13:17:13.841Z
2008-06-23T13:22:13.841Z
爱丽丝
波波

在执行请求时,问:如何将其附加到SOAPpy请求中?

查看有关向soapy请求添加头的文档(https://svn.origo.ethz.ch/playmobil/trunk/contrib/pywebsvcs/SOAPpy/docs/UsingHeaders.txt). 通过这种方式,您可以将自己的自定义头添加到任何请求中

希望这有帮助