dagg
8/7/2018 - 3:21 PM

web_service.py

# zeep needs to be installed
from zeep import Client, helpers
from zeep.wsse.username import UsernameToken

# We use google weather's WSDL to test our script
client = Client('https://graphical.weather.gov/xml/SOAP_server/ndfdXMLserver.php?wsdl')
# the request to the web service will be sent with the zipCodeList argument (we give the value 90210 to the zipcode argument)
req = {"zipCodeList": 90210}
# the response from calling the LatLonListZipCode method (give zipcode to get lat and lon)
resp = client.service.LatLonListZipCode(**req)

'''
The response will be something like that:
"<?xml version='1.0'?><dwml version='1.0' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='https://graphical.weather.gov/xml/DWMLgen/schema/DWML.xsd'><latLonList>34.0995,-118.414</latLonList></dwml>"
'''