Service endpoint interface for python
Question: I am working on java in which eclipse gives some tools like wsimport which
imports all the java files and class files by specifying the URL of the web
service to the tool. Is there some thing like this for python? How do we work
with python to use any web service. There should be some service endpoint
interface for python right? If there is one, How do we use it? Please help,
thanks in advance.


Answer: [Jurko's port of suds](https://bitbucket.org/jurko/suds) will do the job. It's
easy to use, and it exposes a web service's methods and object types.

Example:

    
    
    >>> import suds
    >>> from suds.client import Client
    >>> client = Client('http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL')
    >>> print(client)
    Service ( Weather ) tns="http://ws.cdyne.com/WeatherWS/"
       Prefixes (1)
           ns0 = "http://ws.cdyne.com/WeatherWS/"
       Ports (2):
           (WeatherSoap)
              Methods (3):
                 GetCityForecastByZIP(xs:string ZIP)
                 GetCityWeatherByZIP(xs:string ZIP)
                 GetWeatherInformation()
              Types (8):
                 ArrayOfForecast
                 ArrayOfWeatherDescription
                 Forecast
                 ForecastReturn
                 POP
                 WeatherDescription
                 WeatherReturn
                 temp
    ...
    

As you can see, the `Client` class just requires a URL in order to print out
info for the web service.

    
    
    >>> weather = client.service.GetCityWeatherByZIP('02118')
    >>> print(weather)
    (WeatherReturn){
       Success = True
       ResponseText = "City Found"
       State = "MA"
       City = "Boston"
       WeatherStationCity = "Boston"
       WeatherID = 14
       Description = "Cloudy"
       Temperature = "64"
       RelativeHumidity = "80"
       Wind = "S9"
       Pressure = "30.19F"
       Visibility = None
       WindChill = None
       Remarks = None
     }
    

The `client` object has a `service` attribute that lets you run methods. When
I ran `GetCityWeatherByZIP`, `suds` converted the XML response into a Python
object (in this case, a `WeatherReturn` object). You can access its attributes
like any other Python object.

    
    
    >>> weather.Description
    Cloudy
    >>> weather.Wind
    S9
    

You can also create XML-associated objects of your own with `Client.factory`.

    
    
    >>> forecast = client.factory.create('Forecast')
    >>> forecast.WeatherID = 6
    >>> print(forecast)
    (Forecast){
       Date = None
       WeatherID = 6
       Desciption = None
       Temperatures = 
          (temp){
             MorningLow = None
             DaytimeHigh = None
          }
       ProbabilityOfPrecipiation = 
          (POP){
             Nighttime = None
             Daytime = None
          }
     }
    

Although it's a little dated, [this doc
page](https://fedorahosted.org/suds/wiki/Documentation) should help you get
started.

