Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > nameerror upon calling function

Reply
Thread Tools

nameerror upon calling function

 
 
seancron
Guest
Posts: n/a
 
      09-01-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

 
Reply With Quote
 
 
 
 
Arnaud Delobelle
Guest
Posts: n/a
 
      09-01-2007
On Sep 1, 5:05 pm, seancron <(E-Mail Removed)> wrote:
> 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

--
Arnaud


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Profiler throws NameError on any function Philipp Lies Python 1 03-28-2009 07:58 AM
Calling function depending upon MACRO value param C++ 3 02-23-2006 09:59 AM
Calling Java applet function upon browser close M B HONG 20 Java 1 02-16-2006 08:45 PM
write a function such that when ever i call this function in some other function .it should give me tha data type and value of calling function parameter komal C++ 6 01-25-2005 11:13 AM
calling virtual function results in calling function of base class... Andreas Lagemann C++ 8 01-10-2005 11:03 PM



Advertisments