nameerror upon calling function

S

seancron

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
 
A

Arnaud Delobelle

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

The statement above needs to be in libndfdsoap.py, not here.
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?

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top