有没有一种方法可以向Python Suds客户端提供外部WSDL文件

有没有一种方法可以向Python Suds客户端提供外部WSDL文件,python,soap,wsdl,suds,Python,Soap,Wsdl,Suds,我正在使用一个SOAP服务,其中项目提供一个外部WSDL文件。我正在使用Python+Suds连接到该服务。我遇到问题,因为(https)服务URL看起来像: /sipxconfig/services/UserService?wsdl 但是该URL的WSDL路径与项目提供的外部WSDL文件不匹配。返回的SOAP文档与外部WSDL文件不匹配。所以我的肥皂水客户提出了一个错误 到目前为止,我通过编写一个suds插件来“纠正”返回的soapxml,使其与动态创建的WSDL(在URL处)匹配,从而解决了

我正在使用一个SOAP服务,其中项目提供一个外部WSDL文件。我正在使用Python+Suds连接到该服务。我遇到问题,因为(https)服务URL看起来像:

/sipxconfig/services/UserService?wsdl

但是该URL的WSDL路径与项目提供的外部WSDL文件不匹配。返回的SOAP文档与外部WSDL文件不匹配。所以我的肥皂水客户提出了一个错误

到目前为止,我通过编写一个suds插件来“纠正”返回的soapxml,使其与动态创建的WSDL(在URL处)匹配,从而解决了这个问题。然而,我希望有一种方法可以向subs客户机提供外部WSDL文件,然后将其切换为使用服务的URL

我试过这样的方法:

wsdl_file = os.path.abspath(args.wsdl_file)
client = Client("file://%s" % wsdl_file, transport=t, username=sip_user, password=sip_pwd, doctor=doctor)
client.set_options(location=url)

#Get the results.
user_search = client.factory.create("UserSearch")
user_search.byUserName = args.find_user
user_search.byFuzzyUserNameOrAlias = args.fuzzy
user_search.byGroup = args.group

result = client.service.findUser(user_search)
#^^^
#Error here!
但它最终会导致
MethodNotFound
异常。 我在另一个终端上运行netstat,可以看到客户端没有与外部服务建立网络连接

还有其他人设法从文件中提供sudsdl吗

谢谢,
Carl

所以我确定我的思路是正确的,但是我的SOAP服务有多个端口。我需要做以下工作:

wsdl_file = os.path.abspath(args.wsdl_file)
client = Client("file://%s" % wsdl_file, transport=t, username=sip_user, password=sip_pwd, doctor=doctor)
client.set_options(location=url)

#Get the results.
user_search = client.factory.create("UserSearch")
user_search.byUserName = args.find_user
user_search.byFuzzyUserNameOrAlias = args.fuzzy
user_search.byGroup = args.group

result = client.service['UserService'].findUser(user_search)
#                      ^^^^^^^^^^^^^^^
# This was the missing bit that threw me off!
谢谢,
Carl

您还可以在构建客户端时设置位置选项:
Client(…,location=url)
。谢谢你的例子。