我正在使用Ubuntu 11.04(natty).我一直在使用Suds来使用SOAP Web服务.一切都很好......直到没有.我无法再导入Suds.我已从Ubuntu存储库卸载并重新安装了Suds,但仍然遇到相同的导入错误(请参阅下面的IDLE跟踪).我正在使用Python 2.7.1和Suds 0.4.1-2.有没有人对如何解决这个问题有任何想法?
>>> import suds
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
import suds
File "/usr/lib/pymodules/python2.7/suds/__init__.py", line 154, in <module>
import client
File "/usr/lib/pymodules/python2.7/suds/client.py", line 23, in <module>
import suds.metrics as metrics
File "/usr/lib/pymodules/python2.7/suds/metrics.py", line 23, in <module>
from logging import getLogger
ImportError: cannot import name getLogger
>>>
Run Code Online (Sandbox Code Playgroud) 我需要与SOAP服务进行交互,并且这样做很麻烦; 我真的很感激任何指针.原始错误消息是:
org.apache.axis2.databinding.ADBException: Any type element type has not been given
Run Code Online (Sandbox Code Playgroud)
经过一番研究,事实证明,这是SUDS与服务器之间的分歧,如何应对
type="xsd:anyType"
Run Code Online (Sandbox Code Playgroud)
在有问题的元素上.
我已经确认使用SOAPUI,经过建议,可以通过以下步骤解决问题:
那么,SUDS目前在哪里这样做:
<SOAP-ENV:Envelope ... xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<ns3:Body>
<ns0:method>
<parameter>
<values>
<table>
<key>EMAIL_ADDRESS</key>
<value>example@example.org</value>
</table>
</values>
</parameter>
</ns0:method>
Run Code Online (Sandbox Code Playgroud)
它应该产生这个:
<SOAP-ENV:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" ... xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<ns3:Body>
<ns0:method>
...
<parameter>
<values>
<table>
<key xsi:type="xsd:string">EMAIL_ADDRESS</key>
<value xsi:type="xsd:string">example@example.org</value>
</table>
</values>
</parameter>
</ns0:method>
Run Code Online (Sandbox Code Playgroud)
有没有正确的方法来做到这一点?我已经看到了使用ImportDoctor或MessagePlugins的建议,但还没有真正了解如何实现所需的效果.
尝试使用echosign SOAP API.
wsdl在这里:https://secure.echosign.com/services/EchoSignDocumentService14? wsdl
当我尝试创建某些对象时,即使将其列入其中,它似乎也无法找到该类型 print client
import suds
url = "https://secure.echosign.com/services/EchoSignDocumentService14?wsdl"
client = suds.client.Client(url)
print client
Service ( EchoSignDocumentService14 ) tns="http://api.echosign"
Prefixes (10)
ns0 = "http://api.echosign"
ns1 = "http://dto.api.echosign"
ns2 = "http://dto10.api.echosign"
ns3 = "http://dto11.api.echosign"
ns4 = "http://dto12.api.echosign"
ns5 = "http://dto13.api.echosign"
ns15 = "http://dto14.api.echosign"
ns16 = "http://dto7.api.echosign"
ns17 = "http://dto8.api.echosign"
ns18 = "http://dto9.api.echosign"
Ports (1):
(EchoSignDocumentService14HttpPort)
Methods (45):
...
Types (146):
ns1:CallbackInfo
ns17:WidgetCreationInfo
Run Code Online (Sandbox Code Playgroud)
修剪简洁,但显示名称空间和我现在关注的两种类型.
尝试运行会WCI = client.factory.create("ns17:WidgetCreationInfo")生成此错误:
client.factory.create("ns17:WidgetCreationInfo")Traceback(最近一次调用last):文件"",第1行,在文件"build/bdist.macosx-10.7-intel/egg/suds/client.py"中,行244,in create suds.BuildError:构建(ns17:WidgetCreationInfo)实例时发生错误.因此,无法构造您请求的对象.建议您使用Suds对象手动构造类型.请打开一张带有此错误描述的票证.原因:未找到类型:'(CallbackInfo,http://dto.api.echosign,)'
因此它似乎无法找到CallbackInfo类型.也许是因为它错过了那里的ns?
在我的一个应用程序中,我在GAE python上使用了SUDS WSDL(SOAP)Web服务.
我的Py代码:
url = 'http://203.215.51.43/Gateway/Execute?WSDL'
client = Client(url)
print client
Run Code Online (Sandbox Code Playgroud)
所以它在服务器控制台打印
Suds ( https://fedorahosted.org/suds/ ) version: 0.4 GA build: R699-20100913
Service ( GatewayService ) tns="urn:fks:jcaps:gateway"
Prefixes (2)
ns0 = "http://fks.com/gtwy"
ns1 = "urn:fks:jcaps:gateway:JavaException"
Ports (1):
(Execute)
Methods (1):
redeem(xs:string SessionId, xs:string TerminalId, xs:string StoreCod
e, xs:string CashMemoNo, xs:string CashMemoDate, xs:double InvoiceAmount, xs:str
ing TimeStamp, xs:string CashierId, xs:string MerchantId, ns0:SPCReqDtls SPCReqD
tls, ns0:VoucherReqDtls[] VoucherReqDtls, ns0:CardReqDtls CardReqDtls, )
Types (1):
ns1:JavaExceptionType
Run Code Online (Sandbox Code Playgroud)
实际上我可以在兑换方法中传递字符串,双重类型值,但不能传递数组/列表 …
我正在尝试几个不同的Python SOAP服务器库,我似乎无法让spyne的'hello world'示例工作:https: //github.com/arskom/spyne/blob/master/examples/ helloworld_soap.py
当我运行它时,它启动一个SOAP服务器,我可以在浏览器中成功查看WSDL http://localhost:7789/?wsdl.但是,当我尝试连接suds客户端时,我得到一个例外:
Python 2.7.3 (default, Aug 1 2012, 05:14:39)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from suds.client import Client
>>> c = Client('http://localhost:7789/?wsdl')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/acordiner/ve/local/lib/python2.7/site-packages/suds/client.py", line 112, in __init__
self.wsdl = reader.open(url)
File "/home/acordiner/ve/local/lib/python2.7/site-packages/suds/reader.py", line 152, in open
d = self.fn(url, self.options)
File "/home/acordiner/ve/local/lib/python2.7/site-packages/suds/wsdl.py", line 158, in __init__
self.resolve()
File "/home/acordiner/ve/local/lib/python2.7/site-packages/suds/wsdl.py", …Run Code Online (Sandbox Code Playgroud) 我有一个在Windows 7机器上运行的ASP.NET Web服务.我有两个Linux盒子(Ubuntu 12.04),我试图使用Python 2.7.3和Suds 0.4来点击Web服务.我正在尝试执行的脚本如下:
from suds import client
from suds.transport.https import WindowsHttpAuthenticated
url = "https://webserver.mydomain.com/webservice/services.asmx?WSDL"
ntlm = WindowsHttpAuthenticated(username = "user", password = "pwd")
c = client.Client(url, transport = ntlm)
resp = c.service.GetData()
Run Code Online (Sandbox Code Playgroud)
在我的一个Linux机器上,此代码执行完美,resp并包含从Web服务返回的预期数据.在另一个Linux框中,我收到以下错误消息:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/var/www/dev/local/lib/python2.7/site-packages/suds/client.py", line 542, in __call__
return client.invoke(args, kwargs)
File "/var/www/dev/local/lib/python2.7/site-packages/suds/client.py", line 602, in invoke
result = self.send(soapenv)
File "/var/www/dev/local/lib/python2.7/site-packages/suds/client.py", line 643, in send
result = self.succeeded(binding, reply.message)
File "/var/www/dev/local/lib/python2.7/site-packages/suds/client.py", line 678, …Run Code Online (Sandbox Code Playgroud) 我的Web服务器需要从远程SOAP服务请求数据.这很少发生,所以我不想有任何缓存.实际上,SOAP提供程序有时会更改模式并向其添加新参数 - 因此我每次都必须下载并解析整个模式.
我正在使用此代码:
url = 'http://someurl'
cli = suds.client.Client(url)
cli.set_options(cache=None)
return cli
Run Code Online (Sandbox Code Playgroud)
但这仍然有缓存.并创建/ tmp/suds中的临时数据.如何完全禁用suds缓存?
会改变cli.set_options以.Client(url, cache=None)解决问题吗?对不起,我现在无法自己测试.
如何检查python中安装的suds的版本,我在网上查看,但我找不到一个.
我试试这个.在运行python manage.py shell
>>> import suds
>>> suds
Run Code Online (Sandbox Code Playgroud)
但我运行它时得到了python版本.
<module 'suds' from '/usr/local/lib/python2.7/dist-packages/suds/__init__.pyc'>
Run Code Online (Sandbox Code Playgroud)
我该怎么检查suds版本?
我也尝试suds版本但我得到了这个错误
>>> import suds
>>> suds version
File "<console>", line 1
suds version
^
SyntaxError: invalid syntax
Run Code Online (Sandbox Code Playgroud) python ×8
suds ×8
soap ×6
xml ×2
caching ×1
importerror ×1
ntlm ×1
spyne ×1
web-services ×1
wsdl ×1