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 in Python by Anirudh
• 2,070 points
579 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 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 in Python by Sushma
43 views
0 votes
1 answer
0 votes
1 answer

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

To read from a file you can ...READ MORE

answered Jul 30 in Python by Mohammad
• 3,060 points
34 views
0 votes
1 answer

How to download a file over HTTP using Python?

In Python 2, use urllib2 which comes ...READ MORE

answered Oct 18, 2018 in Python by SDeb
• 13,160 points
56 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 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 282 views
+4 votes
6 answers
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 12,139 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 in Python by Nymeria
• 3,520 points
80 views