Using SUDS SOAP client how do I specify web service URL. I can see clearly that WSDL path is specified in Client constructor but what if I wan't to change web service url?
3 Answers
Suds supports WSDL with multiple services or multiple ports (or both), and without having any detailed information on what you're working with, I am only guessing that this is what you are looking for. This question would be easier to answer if you provided more detail, such as what your Client
instance looks like.
After you have successfully constructed a Client
, you can print
it to see the available services, methods, ports, and types.
The following example is straight from the suds documentation.
Example from suds site:
from suds.client import Client
url = 'http://www.thomas-bayer.com/axis2/services/BLZService?wsdl'
client = Client(url)
print client
Outputs this:
Suds - version: 0.3.7 build: (beta) R550-20090820
Service (BLZService) tns="http://thomas-bayer.com/blz/"
Prefixes (1)
ns0 = "http://thomas-bayer.com/blz/"
Ports (2):
(soap)
Methods (1):
getBank(xs:string blz, )
(soap12)
Methods (1):
getBank(xs:string blz, )
Types (5):
getBankType
getBankResponseType
getBankType
getBankResponseType
detailsType
Service (OtherBLZService) tns="http://thomas-bayer.com/blz/"
Prefixes (1)
ns0 = "http://thomas-bayer.com/blz/"
Ports (2):
(soap)
Methods (1):
getBank(xs:string blz, )
(soap12)
Methods (1):
getBank(xs:string blz, )
Types (5):
getBankType
getBankResponseType
getBankType
getBankResponseType
detailsType
Each service can be accessed in many ways, but here is a different port from each service qualified by method:
## service: BLZService, port: soap12, method: getBank
client.service['BLZService']['soap12'].getBank()
## service: OtherBLZService, port: soap, method: getBank
client.service['OtherBLZService']['soap'].getBank()
Is that the kind of thing you're working with? If so, visit their documentation, which I think you'll find more than adequate. If not, please consider adding as much detail as possible to your question to give us more to work with!

- 33,067
- 9
- 68
- 86
-
2Actually what I was asking is how to modify endpoint (port) address on runtime. Your answer reminded me that this configuration can be in service description. And it was actually there. client.service['BLZService'].setlocation() – Sergej Andrejev Jan 21 '10 at 11:50
-
Awesome, I'm really happy that I was able to help you. Congrats! :) – jathanism Jan 21 '10 at 15:26
-
4Using suds 0.4 this is client.wsdl.services[0].setlocation(new_url) – Mike Fogel Sep 25 '12 at 00:00
You can point the client to different endpoints via two methods:
1) client.set_options(location='http://path/to/your/wsdl') -or- 2) using the client's clone() method. Then use set_options() again. It's really the same as #1 above but you end up with two clients to use, not one.
This latter method is a clean way to create a lightweight clone of your client object - they'll share the parsed wsdl and will only differ on their options, which you set via set_options().
I use both methods and they both work very well.
-Matt

- 924
- 7
- 15
I think you have to create a new Client object for each different URL.

- 10,826
- 3
- 35
- 48
-
But I'm passing WSDL url to Client constructor. What if WSDL and service have different URLs? – Sergej Andrejev Nov 04 '09 at 20:01
-
The WSDL should contain all the details of the service URL. You just need one client object per wsdl and you shouldn't need to worry about the service url (as a client) – robince Nov 04 '09 at 20:29