Some examples on how to connect to the FEWS PI-XML SOAP Web Service:
Python
To get time series from FEWS using Python the following example uses the requests module and reads the time series PI-XML content from the SOAP response.
# Simple example that uses python to get timeSeries from the Delft-FEWS PI Soap Service. import requests import xml.etree.ElementTree as ET soapMessage = """<?xml version="1.0" ?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:few="http://fewspiservice.wldelft.nl"> <soapenv:Header/> <soapenv:Body> <few:getTimeSeries> <few:queryParams> <endTime>2010-01-01T00:00:00Z</endTime> <locationIds>63306260000</locationIds> <parameterIds>T.obs.mean</parameterIds> <startTime>2000-01-01T00:00:00Z</startTime> </few:queryParams> </few:getTimeSeries> </soapenv:Body> </soapenv:Envelope>""" url = 'http://localhost:8080/FewsWebServices/fewspiservice' headers = { "Content-Type": "text/xml", "SOAPAction" : "\"\"" } response = requests.post(url=url, data=soapMessage, headers=headers) data = response.text xmlTree = ET.fromstring(data) piXmlResponse = None for elem in xmlTree.iter(): if elem.tag == 'return': piXmlResponse = elem.text if piXmlResponse is not None: print(piXmlResponse) # For further processing, the PI-XML response can be parsed as well. parsedPiXml = ET.fromstring(piXmlResponse) else: print('No pi xml response found')
To see an