繁体   English   中英

是否可以使用 python suds 从文件系统中读取 wsdl 文件?

[英]Is it possible to use python suds to read a wsdl file from the file system?

从 suds文档中,如果我有 WSDL 的 url,我可以创建一个Client

from suds.client import Client
url = 'http://localhost:7080/webservices/WebServiceTestBean?wsdl'
client = Client(url)

我的文件系统上目前有 WSDL 文件。 是否可以使用 suds 从我的文件系统读取 WSDL 文件而不是将其托管在 Web 服务器上?

尝试使用url='file:///path/to/file'

单线

# Python 3
import urllib, os 
url = urllib.parse.urljoin('file:', urllib.request.pathname2url(os.path.abspath("service.xml")))

这是一个更完整的单衬,它将:

  • 让你只指定本地路径,
  • 给你绝对路径,
  • 然后将其格式化为文件 url。

基于:

原文供参考

# Python 2 (Legacy Python)
import urlparse, urllib, os

url = urlparse.urljoin('file:', urllib.pathname2url(os.path.abspath("service.xml")))

使用路径库:

def wsdl_uri():
    import pathlib
    return pathlib.Path(os.path.abspath("resources/your_definition.wsdl")).as_uri()
    

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM