How to use read a WSDL file from the file system using Python suds?

0 votes

Hi all, so I was checking out the suds documentation. And from what I have learned until now, I am able to create my own client. That is if I have the URL for the WSDL is what I know.

Check out the below snippet:

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

Do note that I have the WSDL file on my file system now already.

My question is simple. Is it possible to make use of suds in this scenario to read the WSDL file from the native file system (mine) and avoid hosting it on a random web server?

All help appreciated!


Jan 21, 2019 in Python by Anirudh
• 2,080 points
2,811 views

1 answer to this question.

0 votes

Hi, good question.

It is a very simple and straightforward answer, to be honest. Make sure you try to use the following as the URL parameter:

url='file:///path/to/file'

This will surely solve your query and you should be up and running quickly.

Here is another snippet of code:

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

This will basically let you specify the local path only and it will also get you the absolute path as well. Win-win.

Hope this helped!

answered Jan 21, 2019 by Nymeria
• 3,520 points

Related Questions In Python

0 votes
1 answer

How to read data from a text file using Python?

Refer to the below example where the ...READ MORE

answered May 12, 2019 in Python by Sushma
363 views
0 votes
2 answers
0 votes
1 answer
0 votes
2 answers

How do you read from a file using file handling in python?

for write, read,append data in file check ...READ MORE

answered Jun 21 in Python by sahil
• 540 points
176 views
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 1,467 views
0 votes
0 answers
+4 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,800 points
1,097 views
0 votes
1 answer

How to get the return value from a thread using python?

You don't need to change your existing ...READ MORE

answered Dec 3, 2018 in Python by Nymeria
• 3,520 points

edited Dec 19, 2018 by Nymeria 42,546 views
0 votes
1 answer

How to create and read from a temporary file in Python?

Hi, there is a very simple solution ...READ MORE

answered Jan 29, 2019 in Python by Nymeria
• 3,520 points
367 views