From bdd0a41aed7edf21ec2a65cfa17a86af2ef8c48a Mon Sep 17 00:00:00 2001 From: dims Date: Tue, 17 Jun 2008 00:23:01 +0000 Subject: Move Tuscany from Incubator to top level. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@668359 13f79535-47bb-0310-9956-ffa450edef68 --- .../sample.weather/Makefile.am | 23 ++++ .../sample.weather/WeatherForecast.wsdl | 133 +++++++++++++++++++++ .../sample.weather/WeatherForecastImpl.py | 65 ++++++++++ .../sample.weather/sample.weather.composite | 36 ++++++ 4 files changed, 257 insertions(+) create mode 100644 tags/native-sca-1.0.incubating-M3/samples/PythonWeatherForecast/sample.weather/Makefile.am create mode 100644 tags/native-sca-1.0.incubating-M3/samples/PythonWeatherForecast/sample.weather/WeatherForecast.wsdl create mode 100644 tags/native-sca-1.0.incubating-M3/samples/PythonWeatherForecast/sample.weather/WeatherForecastImpl.py create mode 100644 tags/native-sca-1.0.incubating-M3/samples/PythonWeatherForecast/sample.weather/sample.weather.composite (limited to 'tags/native-sca-1.0.incubating-M3/samples/PythonWeatherForecast/sample.weather') diff --git a/tags/native-sca-1.0.incubating-M3/samples/PythonWeatherForecast/sample.weather/Makefile.am b/tags/native-sca-1.0.incubating-M3/samples/PythonWeatherForecast/sample.weather/Makefile.am new file mode 100644 index 0000000000..d0450ef707 --- /dev/null +++ b/tags/native-sca-1.0.incubating-M3/samples/PythonWeatherForecast/sample.weather/Makefile.am @@ -0,0 +1,23 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +deploydir=$(prefix)/PythonWeatherForecast/deploy +compositedir=$(deploydir)/sample.weather + +composite_DATA = *.composite *.wsdl *.py +EXTRA_DIST = *.composite *.wsdl *.py + diff --git a/tags/native-sca-1.0.incubating-M3/samples/PythonWeatherForecast/sample.weather/WeatherForecast.wsdl b/tags/native-sca-1.0.incubating-M3/samples/PythonWeatherForecast/sample.weather/WeatherForecast.wsdl new file mode 100644 index 0000000000..ec39e2287a --- /dev/null +++ b/tags/native-sca-1.0.incubating-M3/samples/PythonWeatherForecast/sample.weather/WeatherForecast.wsdl @@ -0,0 +1,133 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tags/native-sca-1.0.incubating-M3/samples/PythonWeatherForecast/sample.weather/WeatherForecastImpl.py b/tags/native-sca-1.0.incubating-M3/samples/PythonWeatherForecast/sample.weather/WeatherForecastImpl.py new file mode 100644 index 0000000000..6e3775de0b --- /dev/null +++ b/tags/native-sca-1.0.incubating-M3/samples/PythonWeatherForecast/sample.weather/WeatherForecastImpl.py @@ -0,0 +1,65 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +# +# +# +# This Python code is a simple sample that calls a service that returns an +# SDO which has been converted into an ElementTree Element object. The Element +# object is then converted into formatted text + +import xml.etree.ElementTree + +def getForecastByPlaceName(placeName): + + print "Python - WeatherForecastImpl.getForecastByPlaceName:", placeName + + xmlResult = weatherWebService.GetWeatherByPlaceName(placeName) + + print "Python - Formatting result from weatherService:", xmlResult + + return formatWeather(xmlResult, placeName) + + +def getForecastByZipCode(zipCode): + + print "Python - WeatherForecastImpl.getForecastByZipCode:", zipCode + + xmlResult = weatherWebService.GetWeatherByZipCode(zipCode) + + print "Python - Formatting result from weatherService:", xmlResult + + return formatWeather(xmlResult, zipCode) + + +def formatWeather(weather, name): + + result = "Could not retrieve Weather Forecast for " + str(name) + + pathAndNS = "./{http://www.webservicex.net}" + + if weather.findtext(pathAndNS+"PlaceName"): + + result = "\n\nWeather Forecast for "+ weather.findtext(pathAndNS+"PlaceName")+ ", "+ weather.findtext(pathAndNS+"StateCode")+"\n" + result += "Latitude: "+ weather.findtext(pathAndNS+"Latitude")+ " Longitude: "+ weather.findtext(pathAndNS+"Longitude")+"\n\n" + + for node in weather.findall(".//{http://www.webservicex.net}WeatherData"): + if node.findtext(pathAndNS+"Day"): result += node.findtext(pathAndNS+"Day") + if node.findtext(pathAndNS+"MaxTemperatureC"): result += ":\tMax "+ node.findtext(pathAndNS+"MaxTemperatureC") + if node.findtext(pathAndNS+"MinTemperatureC"): result += "C. Min "+ node.findtext(pathAndNS+"MinTemperatureC")+ "C.\n" + + return result diff --git a/tags/native-sca-1.0.incubating-M3/samples/PythonWeatherForecast/sample.weather/sample.weather.composite b/tags/native-sca-1.0.incubating-M3/samples/PythonWeatherForecast/sample.weather/sample.weather.composite new file mode 100644 index 0000000000..70e9674d23 --- /dev/null +++ b/tags/native-sca-1.0.incubating-M3/samples/PythonWeatherForecast/sample.weather/sample.weather.composite @@ -0,0 +1,36 @@ + + + + + + + + + WeatherService + + + + + + + + + -- cgit v1.2.3