nameerror upon calling function

seancron seancron at gmail.com
Sat Sep 1 12:05:44 EDT 2007


Hi,

I have a program that makes a call to a function in a different python
script that I wrote.  But, when I call the function I get the
following error:

NameError: global name 'WSDL' is not defined

I can't figure out why I'm getting this error since WSDL should be
defined. Here are the two scripts:

weatherpy.py
from xml.dom import minidom
from SOAPpy import WSDL
from libndfdsoap import ByDaySOAPRequest

wsdlfile = 'http://www.weather.gov/forecasts/xml/DWMLgen/wsdl/
ndfdXML.wsdl'

if __name__ == '__main__':
    ByDaySOAPRequest(39.0000, -77.0000, 2004-04-27, 7, '12 hourly')

libndfdsoap.py
def ByDaySOAPRequest(latitude, longitude, startDate, numDays,
hrFormat):
    """Sends a SOAP request using the NDFDgenByDay method and stores
the
    response in a file called weather.xml"""

    wsdlfile = 'http://www.weather.gov/forecasts/xml/DWMLgen/wsdl/
ndfdXML.wsdl'
    server = WSDL.Proxy(wsdlfile)
    response = server.NDFDgenByDay(latitude, longitude, startDate,
numDays,
                                   hrFormat)
    xml = open('/weather.xml', 'w')
    xml.write(response)
    xml.close()
    return

Can somebody please show me how to fix this error?

Thanks,

-Sean




More information about the Python-list mailing list