创建多个指向同一wsd的suds客户端

2024-10-03 15:25:57 发布

您现在位置:Python中文网/ 问答频道 /正文

打开IDLE并导入suds客户机,我可以通过以下方式创建客户机:

c = Client('http://blah/Core.svc?wsdl')

随后致电:

^{pr2}$

将给我一个抛出的TypeNotFound错误,在wsdl文件中命名一个类。在

我试过:

timeout = 5 # and then waiting
cache = None

但同样的错误也发生了。我不介意我不能使用第一个实例,但是我如何才能掌握第二个实例呢?在

我正在编写测试,这些测试将由PySys的单个实例运行,但它们单独不共享数据。在

顺便说一句,在这之后,当我quit()IDLE时,它会询问我是否要终止正在运行的进程,那么我假设创建一个客户端会触发一个线程,这是正确的吗?在

我得到的错误是:

Traceback (most recent call last):
  File "<pyshell#9>", line 1, in <module>
    c1 = Client('http://localhost:8090/Service/Core.svc?wsdl')
  File "build\bdist.win-amd64\egg\suds\client.py", line 119, in __init__
    sd = ServiceDefinition(self.wsdl, s)
  File "build\bdist.win-amd64\egg\suds\servicedefinition.py", line 58, in __init__
    self.paramtypes()
  File "build\bdist.win-amd64\egg\suds\servicedefinition.py", line 137, in paramtypes
    item = (pd[1], pd[1].resolve())
  File "build\bdist.win-amd64\egg\suds\xsd\sxbasic.py", line 63, in resolve
    raise TypeNotFound(qref)
TypeNotFound: Type not found: '(ClassName, http://schemas.datacontract.org/4004/07/Class.Namespace, )'

c.last_received()和c.last_sent()均为空。在

更进一步,我查看了IIS的日志,发现每当我在python实例中第一次调用Client(url)时,我会得到:

GET /Service/Core.svc   wsdl    8090    -   ::1 Python-urllib/2.6   
GET /Service/Core.svc   xsd=xsd0    8090    -   ::1 Python-urllib/2.6   
GET /Service/Core.svc   xsd=xsd2    8090    -   ::1 Python-urllib/2.6   
GET /Service/Core.svc   xsd=xsd1    8090    -   ::1 Python-urllib/2.6   
GET /Service/Core.svc   xsd=xsd3    8090    -   ::1 Python-urllib/2.6   
GET /Service/Core.svc   xsd=xsd2    8090    -   ::1 Python-urllib/2.6   
GET /Service/Core.svc   xsd=xsd1    8090    -   ::1 Python-urllib/2.6   
GET /Service/Core.svc   xsd=xsd3    8090    -   ::1 Python-urllib/2.6   
GET /Service/Core.svc   xsd=xsd2    8090    -   ::1 Python-urllib/2.6   
GET /Service/Core.svc   xsd=xsd1    8090    -   ::1 Python-urllib/2.6   
GET /Service/Core.svc   xsd=xsd3    8090    -   ::1 Python-urllib/2.6   
GET /Service/Core.svc   xsd=xsd2    8090    -   ::1 Python-urllib/2.6   
GET /Service/Core.svc   xsd=xsd3    8090    -   ::1 Python-urllib/2.6   
GET /Service/Core.svc   xsd=xsd1    8090    -   ::1 Python-urllib/2.6   
GET /Service/Core.svc   xsd=xsd2    8090    -   ::1 Python-urllib/2.6   
GET /Service/Core.svc   xsd=xsd3    8090    -   ::1 Python-urllib/2.6   

但是来自同一python实例的后续调用给了我:

GET /Service/Core.svc   wsdl    8090    -   ::1 Python-urllib/2.6
GET /Service/Core.svc   xsd=xsd0    8090    -   ::1 Python-urllib/2.6
GET /Service/Core.svc   xsd=xsd2    8090    -   ::1 Python-urllib/2.6
GET /Service/Core.svc   xsd=xsd3    8090    -   ::1 Python-urllib/2.6
GET /Service/Core.svc   xsd=xsd1    8090    -   ::1 Python-urllib/2.6
GET /Service/Core.svc   xsd=xsd2    8090    -   ::1 Python-urllib/2.6
GET /Service/Core.svc   xsd=xsd3    8090    -   ::1 Python-urllib/2.6

每次请求某个文件时,响应的大小都是相同的。在


Tags: 实例incoregetservicelineurllibsuds
2条回答

这可能是其他地方的问题(例如,提供WSDL的服务),因为在使用SOAP服务时,我不能在IDLE或python命令shell或脚本(我正在使用windows)中进行复制。在

你能提供确切的错误,suds的版本和问题WSDL的实际URL吗?在

不管我如何尝试,下面的输出都是相同的。在

>>> from suds.client import Client
>>> c1 = Client('http://vocab.nerc.ac.uk/vocab2.wsdl')
>>> c2 = Client('http://vocab.nerc.ac.uk/vocab2.wsdl')
>>> c1
<suds.client.Client object at 0x022AE230>
>>> c2
<suds.client.Client object at 0x022CCDB0>
>>>

编辑:

关于退出空闲的通知,即使您在IDLE中没有运行代码,然后键入quit()关闭

编辑2:

尝试通过使用here(上一次发送的和日志记录)中提到的一些技术来调试它

这个错误不会出现在suds默认值中。 这将出现在下面的applythis patch之后:

recurselevel-schema.py.patch https://github.com/sandersnewmedia/suds/blob/master/suds/xsd/recurselevel-schema.py.patch

在文件中 /suds/xsd/schema.py

此修补程序解决了“递归级别模式错误”,但当您需要处理指向同一wsdl的多个suds客户端时会导致错误。在

相关问题 更多 >