nameerror upon calling function

Discussion in 'Python' started by seancron, Sep 1, 2007.

  1. seancron

    seancron Guest

    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
     
    seancron, Sep 1, 2007
    #1
    1. Advertising

  2. On Sep 1, 5:05 pm, seancron <> 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
     
    Arnaud Delobelle, Sep 1, 2007
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. M B HONG 20
    Replies:
    1
    Views:
    9,664
    Finomosec
    Feb 16, 2006
  2. Andreas Lagemann
    Replies:
    8
    Views:
    515
    Mike Wahler
    Jan 10, 2005
  3. tiwy
    Replies:
    0
    Views:
    457
  4. param
    Replies:
    3
    Views:
    352
    Ivan Vecerina
    Feb 23, 2006
  5. Philipp Lies
    Replies:
    1
    Views:
    1,094
    Gabriel Genellina
    Mar 28, 2009
Loading...

Share This Page