summaryrefslogtreecommitdiffstats
path: root/sca-cpp/branches/cpp-contrib/contrib/samples/RestCustomer/sample.customer.restclient
diff options
context:
space:
mode:
Diffstat (limited to 'sca-cpp/branches/cpp-contrib/contrib/samples/RestCustomer/sample.customer.restclient')
-rw-r--r--sca-cpp/branches/cpp-contrib/contrib/samples/RestCustomer/sample.customer.restclient/Customer.xsd33
-rw-r--r--sca-cpp/branches/cpp-contrib/contrib/samples/RestCustomer/sample.customer.restclient/CustomerRestClient.py85
-rw-r--r--sca-cpp/branches/cpp-contrib/contrib/samples/RestCustomer/sample.customer.restclient/Makefile.am23
-rw-r--r--sca-cpp/branches/cpp-contrib/contrib/samples/RestCustomer/sample.customer.restclient/runrestclient.bat53
-rwxr-xr-xsca-cpp/branches/cpp-contrib/contrib/samples/RestCustomer/sample.customer.restclient/runrestclient.sh50
-rw-r--r--sca-cpp/branches/cpp-contrib/contrib/samples/RestCustomer/sample.customer.restclient/sample.customer.restclient.composite33
6 files changed, 277 insertions, 0 deletions
diff --git a/sca-cpp/branches/cpp-contrib/contrib/samples/RestCustomer/sample.customer.restclient/Customer.xsd b/sca-cpp/branches/cpp-contrib/contrib/samples/RestCustomer/sample.customer.restclient/Customer.xsd
new file mode 100644
index 0000000000..1cec1b0ae6
--- /dev/null
+++ b/sca-cpp/branches/cpp-contrib/contrib/samples/RestCustomer/sample.customer.restclient/Customer.xsd
@@ -0,0 +1,33 @@
+<?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.
+-->
+<xsd:schema targetNamespace="http://sample.customer" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <xsd:element name="customer">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="id" type="xsd:int" />
+ <xsd:element name="firstName" type="xsd:string" />
+ <xsd:element name="lastName" type="xsd:string" />
+ <xsd:element name="address" type="xsd:string" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+</xsd:schema>
diff --git a/sca-cpp/branches/cpp-contrib/contrib/samples/RestCustomer/sample.customer.restclient/CustomerRestClient.py b/sca-cpp/branches/cpp-contrib/contrib/samples/RestCustomer/sample.customer.restclient/CustomerRestClient.py
new file mode 100644
index 0000000000..340da8700d
--- /dev/null
+++ b/sca-cpp/branches/cpp-contrib/contrib/samples/RestCustomer/sample.customer.restclient/CustomerRestClient.py
@@ -0,0 +1,85 @@
+# 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 REST Customer sample
+
+
+from xml.etree import ElementTree as et
+import sca
+
+# Locate the customer resource service
+customerResource = sca.locateservice("CustomerResource")
+
+# Show how to invoke CRUD operations on the customer resource
+# The CRUD operations translate to HTTP POST, GET, PUT and DELETE
+# according to the REST pattern
+
+customer = customerResource.retrieve("2345")
+print "Rest - Retrieved customer " + et.tostring(customer)
+
+customer = et.fromstring("""<customer xmlns="http://sample.customer"><id>1234</id><firstName>Jane</firstName><lastName>Doe</lastName></customer>""")
+url = customerResource.create(customer)
+print "Rest - Created customer " + url
+
+customer = customerResource.retrieve("1234")
+print "Rest - Retrieved customer " + et.tostring(customer)
+
+customer = customerResource.retrieve(url)
+print "Rest - Retrieved by url " + et.tostring(customer)
+
+customer.find("{http://sample.customer}lastName").text="Smith"
+customerResource.update("1234", customer)
+print "Rest - Updated customer 1234"
+
+customer = customerResource.retrieve("1234")
+print "Rest - Retrieved customer " + et.tostring(customer)
+
+customerResource.delete("1234")
+print "Rest - Deleted customer 1234"
+
+# Also show how to use REST binding to invoke remote commands
+# using HTTP GET and XML over HTTP POST, the REST binding
+# uses that command pattern when you don't declare a REST interface
+# on your SCA reference
+
+# Locate the customer command service
+customerCommand = sca.locateservice("CustomerCommand")
+
+# Invoke operations on the customer command service
+customer = customerCommand.retrieve("2345")
+print "Command - Retrieved customer " + et.tostring(customer)
+
+customer = et.fromstring("""<customer xmlns="http://sample.customer"><id>1234</id><firstName>Jane</firstName><lastName>Doe</lastName></customer>""")
+url = customerCommand.create(customer)
+print "Command - Created customer " + url
+
+customer = customerCommand.retrieve("1234")
+print "Command - Retrieved customer " + et.tostring(customer)
+
+customer.find("{http://sample.customer}lastName").text="Smith"
+customerCommand.update("1234", customer)
+print "Command - Updated customer 1234"
+
+customer = customerCommand.retrieve("1234")
+print "Command - Retrieved customer " + et.tostring(customer)
+
+customerCommand.delete("1234")
+print "Command - Deleted customer 1234"
diff --git a/sca-cpp/branches/cpp-contrib/contrib/samples/RestCustomer/sample.customer.restclient/Makefile.am b/sca-cpp/branches/cpp-contrib/contrib/samples/RestCustomer/sample.customer.restclient/Makefile.am
new file mode 100644
index 0000000000..13c14d07e9
--- /dev/null
+++ b/sca-cpp/branches/cpp-contrib/contrib/samples/RestCustomer/sample.customer.restclient/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)/RestCustomer/deploy
+restclientdir=$(deploydir)/sample.customer.restclient
+
+restclient_DATA = *.py *.composite *.xsd
+restclient_SCRIPTS = runrestclient.sh
+EXTRA_DIST = runrestclient.sh *.py *.composite *.xsd
diff --git a/sca-cpp/branches/cpp-contrib/contrib/samples/RestCustomer/sample.customer.restclient/runrestclient.bat b/sca-cpp/branches/cpp-contrib/contrib/samples/RestCustomer/sample.customer.restclient/runrestclient.bat
new file mode 100644
index 0000000000..982b9b5e83
--- /dev/null
+++ b/sca-cpp/branches/cpp-contrib/contrib/samples/RestCustomer/sample.customer.restclient/runrestclient.bat
@@ -0,0 +1,53 @@
+@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 "%LIBCURL_HOME%" == "" (
+echo LIBCURL_HOME not set
+goto end
+)
+echo using Libcurl installed at %LIBCURL_HOME%
+
+set PATH=%HTTPD_HOME%\bin;%LIBCURL_HOME%\lib;%TUSCANY_SCACPP%\extensions\rest\interface\bin;%TUSCANY_SCACPP%\extensions\rest\reference\bin;%TUSCANY_SCACPP%\extensions\python\bin;%TUSCANY_SCACPP%\bin;%TUSCANY_SDOCPP%\bin;%PATH%
+set PYTHONPATH=%TUSCANY_SCACPP%\extensions\python\bin
+
+set TUSCANY_SCACPP_ROOT=%~d0%~p0\..\
+set TUSCANY_SCACPP_COMPONENT=sample.customer.CustomerRestClientComponent
+set TUSCANY_SCACPP_BASE_URI=http://localhost:9090
+
+set CUSTOMER_DIR=%TUSCANY_SCACPP_ROOT%\sample.customer
+
+cd %TUSCANY_SCACPP_ROOT%\sample.customer.restclient
+python CustomerRestClient.py
+
+:end
+endlocal
diff --git a/sca-cpp/branches/cpp-contrib/contrib/samples/RestCustomer/sample.customer.restclient/runrestclient.sh b/sca-cpp/branches/cpp-contrib/contrib/samples/RestCustomer/sample.customer.restclient/runrestclient.sh
new file mode 100755
index 0000000000..54c068f4e2
--- /dev/null
+++ b/sca-cpp/branches/cpp-contrib/contrib/samples/RestCustomer/sample.customer.restclient/runrestclient.sh
@@ -0,0 +1,50 @@
+#!/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$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:$LD_LIBRARY_PATH
+export PYTHONPATH=$TUSCANY_SCACPP/extensions/python/lib:$PYTHONPATH
+
+export TUSCANY_SCACPP_ROOT=$APFULLDIR/../
+export TUSCANY_SCACPP_COMPONENT=sample.customer.CustomerRestClientComponent
+export TUSCANY_SCACPP_BASE_URI=http://localhost:9090
+
+export CUSTOMER_DIR=$TUSCANY_SCACPP_ROOT/sample.customer
+
+cd $TUSCANY_SCACPP_ROOT/sample.customer.restclient
+python CustomerRestClient.py
diff --git a/sca-cpp/branches/cpp-contrib/contrib/samples/RestCustomer/sample.customer.restclient/sample.customer.restclient.composite b/sca-cpp/branches/cpp-contrib/contrib/samples/RestCustomer/sample.customer.restclient/sample.customer.restclient.composite
new file mode 100644
index 0000000000..15072f28f8
--- /dev/null
+++ b/sca-cpp/branches/cpp-contrib/contrib/samples/RestCustomer/sample.customer.restclient/sample.customer.restclient.composite
@@ -0,0 +1,33 @@
+<?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.customer.restclient">
+
+ <reference name="CustomerResource">
+ <interface.rest/>
+ <binding.rest/>
+ </reference>
+
+ <reference name="CustomerCommand">
+ <binding.rest/>
+ </reference>
+
+</composite> \ No newline at end of file