Skip to main content
 首页 » 编程设计

python之如何从 Python 调用 SOA Web 服务上的方法

2025年02月15日48haluo1

我有一个本地开发框,我在其中配置了 Python。 不同网络上有另一台服务器。 SOA Web 服务位于其中。他们公开了一个应用程序。

应用程序中有一些方法可以执行多个操作。像 getAssetDetails()getPhonenumberByContact() 等。现在我想通过发送和接收 XML 从本地使用 python 使用这些方法。我真正需要什么才能访问这些方法?

我懂一点脚本编写,但对这个领域还是初学者。非常感谢。

请您参考如下方法:

# Use Python 2.7 (64/32) depends on your system type 
# System 64, Python 64, suds 64 OR System 32, Python 32, suds 32 
# Install SUDS, pip install suds or download and install 
from suds.client import Client 
 
xml_request = '''your request xml''' 
def yourfunctionname(_xml_request): 
    url = 'http://wsdl_url?wsdl' 
    client = Client(url) 
    xml = Raw(_xml_main) 
    responsedata = (client.service.yourMethodName(__inject={'msg': xml})) 
    return respdata 
 
getData=yourfunctionname(xml_request) 
for i in getData: 
    print(i)