diff options
author | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2010-02-28 19:40:06 +0000 |
---|---|---|
committer | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2010-02-28 19:40:06 +0000 |
commit | e982b4ef38fd043c15e89bdd60763b10434a087e (patch) | |
tree | 6b9d9c3fc9aff22edb0f137040164c1cbf2359af /sca-cpp/branches/cpp-contrib/contrib/samples/PythonWeatherForecast | |
parent | 64e2486555a0a14f7d9690c2fc62c30bde803a91 (diff) |
Moving old inactive code to a branch as it's confusing code assist, searches and indexing in trunk.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@917273 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-cpp/branches/cpp-contrib/contrib/samples/PythonWeatherForecast')
12 files changed, 702 insertions, 0 deletions
diff --git a/sca-cpp/branches/cpp-contrib/contrib/samples/PythonWeatherForecast/Makefile.am b/sca-cpp/branches/cpp-contrib/contrib/samples/PythonWeatherForecast/Makefile.am new file mode 100644 index 0000000000..6b2d218134 --- /dev/null +++ b/sca-cpp/branches/cpp-contrib/contrib/samples/PythonWeatherForecast/Makefile.am @@ -0,0 +1,21 @@ +# 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 +SUBDIRS = sample.weather sample.weather.client +EXTRA_DIST = *.composite README.html +deploy_DATA = *.composite diff --git a/sca-cpp/branches/cpp-contrib/contrib/samples/PythonWeatherForecast/README b/sca-cpp/branches/cpp-contrib/contrib/samples/PythonWeatherForecast/README new file mode 100644 index 0000000000..c590973f5f --- /dev/null +++ b/sca-cpp/branches/cpp-contrib/contrib/samples/PythonWeatherForecast/README @@ -0,0 +1,20 @@ +Tuscany SCA for C++ Samples - Weather Sample +============================================ + +This is a very simple sample to show how an SCA composite can wire together +two components to implement calls to a Weather Forecast web service + +There are three sub projects in this workspace: + - sample.weather + This contains the source code and SCDL artifacts for the SCA Weather + composite implementing the calls to the Weather web services. + + - sample.weather.client + A sample client which does a local call to the SCA Weather service. + + +Additionally, there is the sample.weather.app.composite file. This +describes the configuration of the SCA Weather composite deployed to the +SCA runtime. + +See the README.html file for instructions to build and run this sample diff --git a/sca-cpp/branches/cpp-contrib/contrib/samples/PythonWeatherForecast/README.html b/sca-cpp/branches/cpp-contrib/contrib/samples/PythonWeatherForecast/README.html new file mode 100644 index 0000000000..c52cb6ec86 --- /dev/null +++ b/sca-cpp/branches/cpp-contrib/contrib/samples/PythonWeatherForecast/README.html @@ -0,0 +1,200 @@ + +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<!-- + 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. +--> + +<HTML> +<HEAD> + <META CONTENT="text/html; charset=iso-8859-1" HTTP-EQUIV="Content-Type"> + <META CONTENT="text/css" HTTP-EQUIV="Content-Style-Type"> + <STYLE MEDIA="all" TYPE="text/css"> +@import url("../../doc/css/maven-base.css"); +@import url("../../doc/css/maven-theme.css"); + </STYLE> + + <LINK HREF="../doc/css/maven-theme.css" MEDIA="print" REL="stylesheet" + TYPE="text/css"> + <TITLE>Tuscany SCA Native Samples - PythonWeatherForecast Sample</TITLE> +</HEAD> + +<BODY> +<DIV ID="bodyColumn"> + <DIV ID="contentBox"> + <DIV CLASS="section"> + <H1>Tuscany SCA Native Samples - PythonWeatherForecast Sample</H1> + + <P>This is a very simple sample to show how an SCA composite can wire + together two components to implement calls to a Weather Forecast web service. + </P> + <P>The PythonWeatherForecast sample requires the following extensions: + <UL> + <LI><A HREF="../../doc/Axis2CWSExtension.html">Axis2/C Web Service Reference Extension</A></LI> + <LI><A HREF="../../doc/PythonExtension.html">Python Extension</A></LI> + </UL> + Please follow the documentation to ensure you have these extensions built and installed + on your system + </P> + <P>There are two sub projects in this workspace:</P> + <UL> + <LI>sample.weather<BR/> + This contains the source code and SCDL artifacts for the SCA Weather + composite implementing the calls to the Weather web services. + </LI> + <LI>sample.weather.client<BR/> + A sample client which does a local call to the SCA Weather service. + </LI> + </UL> + <P>Additionally, there is the sample.weather.app.composite file. This + describes the configuration of the SCA Weather composite deployed to the SCA + runtime. + </P> + + </DIV> + + <DIV CLASS="section"> + <H2>Contents</H2> + <OL> + <LI><A HREF="#linuxbld">Building the PythonWeatherForecast sample on Linux and Mac OS X</A></LI> + <LI><A HREF="#linuxrun">Running the PythonWeatherForecast sample on Linux and Mac OS X</A></LI> + <LI><A HREF="#winbld">Building the PythonWeatherForecast sample on Windows</A></LI> + <LI><A HREF="#winrun">Running the PythonWeatherForecast sample on Windows</A></LI> + <LI><A HREF="#help">Getting help</A></LI> + </OL> + </DIV> + + + <DIV CLASS="section"> + <A NAME="linuxbld"><H2>Building the PythonWeatherForecast sample on Linux and Mac OS X</H2></A> + <P>If using the binary distribution the samples are built and installed in + <tuscany_sca_install_dir>/samples - go directly to <A HREF="#linuxrun">Running the samples on Linux and Mac OS X</A>.</P> + <OL> + <LI>The following environment variables are required: + <UL> + <LI>TUSCANY_SCACPP=<path to installed Tuscany SCA></LI> + <LI>TUSCANY_SDOCPP=<path to installed Tuscany SDO></LI> + </UL> + </LI> + <LI>As the PythonWeatherForecast sample is based on Python scripts, a specific compilation step is not necessary - + only deployment is required. Deploy the Python samples only with the following command sequence: + <UL> + <LI>cd <tuscany_sca_install_dir>/samples</LI> + <LI>./configure --enable-python --enable-cpp=no --prefix=$TUSCANY_SCACPP/samples</LI> + <LI>make install</LI> + </UL> + NOTE: If you don't provide the --prefix configure option, it will by default install into + /usr/local/tuscany/sca/samples/PythonWeatherForecast</LI> + </OL> + </DIV> + + <DIV CLASS="section"> + <A NAME="linuxrun"><H2>Running the PythonWeatherForecast sample on Linux and Mac OS X</H2></A> + <OL> + <LI>The PythonWeatherForecast sample requires the following extensions: + <UL> + <LI><A HREF="../../doc/Axis2CWSExtension.html">Axis2/C Web Service Reference Extension</A></LI> + <LI><A HREF="../../doc/PythonExtension.html">Python Extension</A></LI> + </UL> + Please follow the documentation to ensure you have these extensions built and installed + on your system + </LI> + <LI>The following environment variables are required: + <UL> + <LI>TUSCANY_SCACPP=<path to installed Tuscany SCA></LI> + <LI>TUSCANY_SDOCPP=<path to installed Tuscany SDO></LI> + <LI>AXIS2C_HOME=<path to Axis2/C version 0.96></LI> + <LI>PYTHON_LIB=<path to the Python library><BR/> + Note: If you are using a default installation of Python 2.5 this is usually /usr/lib</LI> + </UL> + </LI> + <LI>Run the sample with the following commands: + <UL> + <LI>cd <tuscany_sca_install_dir>/samples/PythonWeatherForecast/deploy/sample.weather.client</LI> + <LI>./runclient.sh</LI> + </UL> + </LI> + </OL> + </DIV> + + <DIV CLASS="section"> + <A NAME="winbld"><H2>Building the PythonWeatherForecast sample on Windows</H2></A> + <P>If using the binary distribution the samples are built and installed in + <tuscany_sca_install_dir>\samples - go directly to <A HREF="#winrun">Running the samples on Windows</A>.</P> + <OL> + <LI>The following environment variables are required: + <UL> + <LI>TUSCANY_SCACPP=<path to installed Tuscany SCA> + <LI>TUSCANY_SDOCPP=<path to installed Tuscany SDO> + </UL></LI> + </LI> + <LI>As this sample is based on Python scripts, a specific compilation step is not necessary - + only deployment is required. Deploy the sample with the following commands: + <UL> + <LI>cd <tuscany_sca_install_dir>\samples\PythonWeatherForecast</LI> + <LI>deploy.bat</LI> + </UL> + </LI> + </OL> + </DIV> + + <DIV CLASS="section"> + <A NAME="winrun"><H2>Running the PythonWeatherForecast sample on Windows</H2></A> + <OL> + <LI>The PythonWeatherForecast sample requires the following extensions: + <UL> + <LI><A HREF="../../doc/Axis2CWSExtension.html">Axis2/C Web Service Reference Extension</A></LI> + <LI><A HREF="../../doc/PythonExtension.html">Python Extension</A></LI> + </UL> + Please follow the documentation to ensure you have these extensions built and installed + on your system + </LI> + <LI>The following environment variables are required: + <UL> + <LI>TUSCANY_SCACPP=<path to installed Tuscany SCA></LI> + <LI>TUSCANY_SDOCPP=<path to installed Tuscany SDO></LI> + <LI>AXIS2C_HOME=<path to Axis2/C version 0.96></LI> + </UL> + </LI> + <LI>Run the sample with the following commands: + <UL> + <LI>cd <tuscany_sca_install_dir>\samples\PythonWeatherForecast\deploy\sample.weather.client</LI> + <LI>runclient.bat</LI> + </UL> + </LI> + </OL> + </DIV> + + <DIV CLASS="section"> + <A NAME="help"><H2>Getting Help</H2></A> + + <P>The first place to look is at the Tuscany SCA FAQ at + <A HREF="http://cwiki.apache.org/confluence/display/TUSCANY/Tuscany+SCA+-+FAQ" + TARGET="_blank">http://cwiki.apache.org/confluence/display/TUSCANY/Tuscany+SCA+-+FAQ</A> </P> + + <P>Any problem with this release can be reported to the Tuscany + <A HREF="http://cwiki.apache.org/TUSCANY/mailing-lists.html" + TARGET="_blank">mailing lists</A> or create a JIRA issue at <A HREF="http://issues.apache.org/jira/browse/Tuscany" + TARGET="_blank">http://issues.apache.org/jira/browse/Tuscany</A>.</P> + + </DIV> + </DIV> +</DIV> +</BODY> + +</HTML> + diff --git a/sca-cpp/branches/cpp-contrib/contrib/samples/PythonWeatherForecast/sample.weather.app.composite b/sca-cpp/branches/cpp-contrib/contrib/samples/PythonWeatherForecast/sample.weather.app.composite new file mode 100644 index 0000000000..522a2fc0c8 --- /dev/null +++ b/sca-cpp/branches/cpp-contrib/contrib/samples/PythonWeatherForecast/sample.weather.app.composite @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + 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. +--> + +<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" + name="sample.weather.app"> + + <component name="sample.weather.WeatherForecastComponent"> + <implementation.composite name="sample.weather" /> + </component> + +</composite> diff --git a/sca-cpp/branches/cpp-contrib/contrib/samples/PythonWeatherForecast/sample.weather.client/Makefile.am b/sca-cpp/branches/cpp-contrib/contrib/samples/PythonWeatherForecast/sample.weather.client/Makefile.am new file mode 100644 index 0000000000..8c4781759e --- /dev/null +++ b/sca-cpp/branches/cpp-contrib/contrib/samples/PythonWeatherForecast/sample.weather.client/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 +clientdir=$(deploydir)/sample.weather.client + +client_DATA = *.py +client_SCRIPTS = runclient.sh +EXTRA_DIST = runclient.sh *.py diff --git a/sca-cpp/branches/cpp-contrib/contrib/samples/PythonWeatherForecast/sample.weather.client/runclient.bat b/sca-cpp/branches/cpp-contrib/contrib/samples/PythonWeatherForecast/sample.weather.client/runclient.bat new file mode 100644 index 0000000000..93c044ed82 --- /dev/null +++ b/sca-cpp/branches/cpp-contrib/contrib/samples/PythonWeatherForecast/sample.weather.client/runclient.bat @@ -0,0 +1,50 @@ +@echo off + +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. + +setlocal + +if "%TUSCANY_SCACPP%" == "" ( +echo "TUSCANY_SCACPP not set" +goto end +) +echo using SCA installed at %TUSCANY_SCACPP% + +if "%TUSCANY_SDOCPP%" == "" ( +echo "TUSCANY_SDOCPP not set" +goto end +) +echo using SDO installed at %TUSCANY_SDOCPP% + +if "%AXIS2C_HOME%" == "" ( +echo "AXIS2C_HOME not set" +goto end +) +echo using Axis2C installed at %AXIS2C_HOME% + +set PATH=%TUSCANY_SCACPP%\bin;%TUSCANY_SCACPP%\extensions\python\bin;%TUSCANY_SDOCPP%\bin;%AXIS2C_HOME%\lib;%PATH% +set PYTHONPATH=%TUSCANY_SCACPP%\extensions\python\bin + +set TUSCANY_SCACPP_ROOT=%~d0%~p0\..\ +set TUSCANY_SCACPP_COMPONENT=sample.weather.WeatherForecastComponent + +cd %TUSCANY_SCACPP_ROOT%\sample.weather.client +python weather_forecast_client.py + +:end +endlocal diff --git a/sca-cpp/branches/cpp-contrib/contrib/samples/PythonWeatherForecast/sample.weather.client/runclient.sh b/sca-cpp/branches/cpp-contrib/contrib/samples/PythonWeatherForecast/sample.weather.client/runclient.sh new file mode 100755 index 0000000000..e6ec73b209 --- /dev/null +++ b/sca-cpp/branches/cpp-contrib/contrib/samples/PythonWeatherForecast/sample.weather.client/runclient.sh @@ -0,0 +1,54 @@ +#!/bin/sh + +# 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. + +APFULLDIR=`pwd` + +if [ x$TUSCANY_SCACPP = x ]; then +echo "TUSCANY_SCACPP not set" +exit; +fi +echo "Using SCA installed at $TUSCANY_SCACPP" + +if [ x$TUSCANY_SDOCPP = x ]; then +echo "TUSCANY_SDOCPP not set" +exit; +fi +echo "Using SDO installed at $TUSCANY_SDOCPP" + +if [ x$AXIS2C_HOME = x ]; then +echo "AXIS2C_HOME not set" +exit; +fi +echo "Using Axis2C installed at $AXIS2C_HOME" + +if [ x$PYTHON_LIB != x ]; then +echo "Using Python library installed at $PYTHON_LIB" +export LD_LIBRARY_PATH=$PYTHON_LIB:$LD_LIBRARY_PATH +export PATH=$PYTHON_LIB/../bin:$PATH +fi + +export LD_LIBRARY_PATH=$TUSCANY_SCACPP/lib:$TUSCANY_SCACPP/extensions/python/lib:$TUSCANY_SDOCPP/lib:$AXIS2C_HOME/lib:$LD_LIBRARY_PATH +export PYTHONPATH=$TUSCANY_SCACPP/extensions/python/lib:$PYTHONPATH + +export TUSCANY_SCACPP_ROOT=$APFULLDIR/../ +export TUSCANY_SCACPP_COMPONENT=sample.weather.WeatherForecastComponent + +cd $TUSCANY_SCACPP_ROOT/sample.weather.client +python weather_forecast_client.py + diff --git a/sca-cpp/branches/cpp-contrib/contrib/samples/PythonWeatherForecast/sample.weather.client/weather_forecast_client.py b/sca-cpp/branches/cpp-contrib/contrib/samples/PythonWeatherForecast/sample.weather.client/weather_forecast_client.py new file mode 100644 index 0000000000..5de99fcf8e --- /dev/null +++ b/sca-cpp/branches/cpp-contrib/contrib/samples/PythonWeatherForecast/sample.weather.client/weather_forecast_client.py @@ -0,0 +1,49 @@ +# 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 provides a Python +# client for the WeatherForecast sample + + +import sys +import sca +import xml.etree.ElementTree + + + +# The main script: + +# Locate the Weather service +weatherService = sca.locateservice("WeatherComponent") + +place = "San Jose" +print "\nFinding Weather Forecast for", place +weatherText = weatherService.getForecastByPlaceName(place) +print weatherText + +zip = 90210 +print "\nFinding Weather Forecast for zip code", zip +weatherText = weatherService.getForecastByZipCode(zip) +print weatherText + + + + + diff --git a/sca-cpp/branches/cpp-contrib/contrib/samples/PythonWeatherForecast/sample.weather/Makefile.am b/sca-cpp/branches/cpp-contrib/contrib/samples/PythonWeatherForecast/sample.weather/Makefile.am new file mode 100644 index 0000000000..d0450ef707 --- /dev/null +++ b/sca-cpp/branches/cpp-contrib/contrib/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/sca-cpp/branches/cpp-contrib/contrib/samples/PythonWeatherForecast/sample.weather/WeatherForecast.wsdl b/sca-cpp/branches/cpp-contrib/contrib/samples/PythonWeatherForecast/sample.weather/WeatherForecast.wsdl new file mode 100644 index 0000000000..ec39e2287a --- /dev/null +++ b/sca-cpp/branches/cpp-contrib/contrib/samples/PythonWeatherForecast/sample.weather/WeatherForecast.wsdl @@ -0,0 +1,133 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + 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. +--> +<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns:tns="http://www.webservicex.net" + targetNamespace="http://www.webservicex.net" + xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"> + <wsdl:types> + <xsd:schema elementFormDefault="qualified" targetNamespace="http://www.webservicex.net"> + <xsd:element name="GetWeatherByZipCode"> + <xsd:complexType> + <xsd:sequence> + <xsd:element minOccurs="0" maxOccurs="1" name="ZipCode" type="xsd:string" /> + </xsd:sequence> + </xsd:complexType> + </xsd:element> + <xsd:element name="GetWeatherByZipCodeResponse"> + <xsd:complexType> + <xsd:sequence> + <xsd:element minOccurs="1" maxOccurs="1" name="GetWeatherByZipCodeResult" type="tns:WeatherForecasts" /> + </xsd:sequence> + </xsd:complexType> + </xsd:element> + <xsd:complexType name="WeatherForecasts"> + <xsd:sequence> + <xsd:element minOccurs="1" maxOccurs="1" name="Latitude" type="xsd:float" /> + <xsd:element minOccurs="1" maxOccurs="1" name="Longitude" type="xsd:float" /> + <xsd:element minOccurs="1" maxOccurs="1" name="AllocationFactor" type="xsd:float" /> + <xsd:element minOccurs="0" maxOccurs="1" name="FipsCode" type="xsd:string" /> + <xsd:element minOccurs="0" maxOccurs="1" name="PlaceName" type="xsd:string" /> + <xsd:element minOccurs="0" maxOccurs="1" name="StateCode" type="xsd:string" /> + <xsd:element minOccurs="0" maxOccurs="1" name="Status" type="xsd:string" /> + <xsd:element minOccurs="0" maxOccurs="1" name="Details" type="tns:ArrayOfWeatherData" /> + </xsd:sequence> + </xsd:complexType> + <xsd:complexType name="ArrayOfWeatherData"> + <xsd:sequence> + <xsd:element minOccurs="0" maxOccurs="unbounded" name="WeatherData" type="tns:WeatherData" /> + </xsd:sequence> + </xsd:complexType> + <xsd:complexType name="WeatherData"> + <xsd:sequence> + <xsd:element minOccurs="0" maxOccurs="1" name="Day" type="xsd:string" /> + <xsd:element minOccurs="0" maxOccurs="1" name="WeatherImage" type="xsd:string" /> + <xsd:element minOccurs="0" maxOccurs="1" name="MaxTemperatureF" type="xsd:string" /> + <xsd:element minOccurs="0" maxOccurs="1" name="MinTemperatureF" type="xsd:string" /> + <xsd:element minOccurs="0" maxOccurs="1" name="MaxTemperatureC" type="xsd:string" /> + <xsd:element minOccurs="0" maxOccurs="1" name="MinTemperatureC" type="xsd:string" /> + </xsd:sequence> + </xsd:complexType> + <xsd:element name="GetWeatherByPlaceName"> + <xsd:complexType> + <xsd:sequence> + <xsd:element minOccurs="0" maxOccurs="1" name="PlaceName" type="xsd:string" /> + </xsd:sequence> + </xsd:complexType> + </xsd:element> + <xsd:element name="GetWeatherByPlaceNameResponse"> + <xsd:complexType> + <xsd:sequence> + <xsd:element minOccurs="1" maxOccurs="1" name="GetWeatherByPlaceNameResult" type="tns:WeatherForecasts" /> + </xsd:sequence> + </xsd:complexType> + </xsd:element> + <xsd:element name="WeatherForecasts" type="tns:WeatherForecasts" /> + </xsd:schema> + </wsdl:types> + <wsdl:message name="GetWeatherByZipCodeRequest"> + <wsdl:part name="parameters" element="tns:GetWeatherByZipCode" /> + </wsdl:message> + <wsdl:message name="GetWeatherByZipCodeResponse"> + <wsdl:part name="parameters" element="tns:GetWeatherByZipCodeResponse" /> + </wsdl:message> + <wsdl:message name="GetWeatherByPlaceNameRequest"> + <wsdl:part name="parameters" element="tns:GetWeatherByPlaceName" /> + </wsdl:message> + <wsdl:message name="GetWeatherByPlaceNameResponse"> + <wsdl:part name="parameters" element="tns:GetWeatherByPlaceNameResponse" /> + </wsdl:message> + <wsdl:portType name="WeatherForecastPortType"> + <wsdl:operation name="GetWeatherByZipCode"> + <wsdl:input message="tns:GetWeatherByZipCodeRequest" /> + <wsdl:output message="tns:GetWeatherByZipCodeResponse" /> + </wsdl:operation> + <wsdl:operation name="GetWeatherByPlaceName"> + <wsdl:input message="tns:GetWeatherByPlaceNameRequest" /> + <wsdl:output message="tns:GetWeatherByPlaceNameResponse" /> + </wsdl:operation> + </wsdl:portType> + <wsdl:binding name="WeatherForecastSoapBinding" type="tns:WeatherForecastPortType"> + <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" /> + <wsdl:operation name="GetWeatherByZipCode"> + <soap:operation soapAction="http://www.webservicex.net/GetWeatherByZipCode" style="document" /> + <wsdl:input> + <soap:body use="literal" /> + </wsdl:input> + <wsdl:output> + <soap:body use="literal" /> + </wsdl:output> + </wsdl:operation> + <wsdl:operation name="GetWeatherByPlaceName"> + <soap:operation soapAction="http://www.webservicex.net/GetWeatherByPlaceName" style="document" /> + <wsdl:input> + <soap:body use="literal" /> + </wsdl:input> + <wsdl:output> + <soap:body use="literal" /> + </wsdl:output> + </wsdl:operation> + </wsdl:binding> + <wsdl:service name="WeatherForecast"> + <wsdl:port name="WeatherForecastPort" binding="tns:WeatherForecastSoapBinding"> + <soap:address location="http://www.webservicex.net/WeatherForecast.asmx" /> + </wsdl:port> + </wsdl:service> +</wsdl:definitions>
\ No newline at end of file diff --git a/sca-cpp/branches/cpp-contrib/contrib/samples/PythonWeatherForecast/sample.weather/WeatherForecastImpl.py b/sca-cpp/branches/cpp-contrib/contrib/samples/PythonWeatherForecast/sample.weather/WeatherForecastImpl.py new file mode 100644 index 0000000000..6e3775de0b --- /dev/null +++ b/sca-cpp/branches/cpp-contrib/contrib/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/sca-cpp/branches/cpp-contrib/contrib/samples/PythonWeatherForecast/sample.weather/sample.weather.composite b/sca-cpp/branches/cpp-contrib/contrib/samples/PythonWeatherForecast/sample.weather/sample.weather.composite new file mode 100644 index 0000000000..70e9674d23 --- /dev/null +++ b/sca-cpp/branches/cpp-contrib/contrib/samples/PythonWeatherForecast/sample.weather/sample.weather.composite @@ -0,0 +1,36 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + 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. +--> + +<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" + name="sample.weather"> + + <component name="WeatherComponent"> + <implementation.python module="WeatherForecastImpl"/> + <!--implementation.ruby script="WeatherForecastImpl.rb" class="WeatherForecastImpl"/--> + <reference name="weatherWebService">WeatherService</reference> + </component> + + <reference name="WeatherService"> + <interface.wsdl interface="http://www.webservicex.net#wsdl.interface(WeatherForecastPortType)"/> + <binding.ws endpoint="http://www.webservicex.net#wsdl.endpoint(WeatherForecast/WeatherForecastPort)"/> + <!--binding.ws uri="http://www.webservicex.net/WeatherForecast.asmx"/--> + </reference> + +</composite> |