简体   繁体   English

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

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

From suds documentation , I can create a Client if I have a url for the WSDL.从 suds文档中,如果我有 WSDL 的 url,我可以创建一个Client

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

I currently have the WSDL file on my file system.我的文件系统上目前有 WSDL 文件。 Is it possible to use suds to read the WSDL file from my file system instead of hosting it on a web server?是否可以使用 suds 从我的文件系统读取 WSDL 文件而不是将其托管在 Web 服务器上?

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

Oneliner单线

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

This is a more complete one liner that will:这是一个更完整的单衬,它将:

  • let you specify just the local path,让你只指定本地路径,
  • get you the absolute path,给你绝对路径,
  • and then format it as a file-url.然后将其格式化为文件 url。

Based upon:基于:

Original for reference原文供参考

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

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

Using pathlib:使用路径库:

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