簡體   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