diff options
author | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2009-11-16 06:35:50 +0000 |
---|---|---|
committer | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2009-11-16 06:35:50 +0000 |
commit | 034ecc7803559acdda5dd6c54ecc081665b19f61 (patch) | |
tree | 7485982d141aba0577b0eb11d5fef083876e4ed3 /sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator | |
parent | b72b7e219af9b9c6826372eeb581ee85ca653d75 (diff) |
Cleaning up SVN structure, moving tag under sca-cpp/tags.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@880618 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator')
30 files changed, 2085 insertions, 0 deletions
diff --git a/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/Makefile.am b/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/Makefile.am new file mode 100644 index 0000000000..88ec180a84 --- /dev/null +++ b/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/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)/samples/Calculator/deploy +SUBDIRS = sample.calculator sample.calculator.client sample.calculator.wsclient +EXTRA_DIST = *.composite README.html +deploy_DATA = *.composite diff --git a/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/README b/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/README new file mode 100644 index 0000000000..4104ff46b6 --- /dev/null +++ b/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/README @@ -0,0 +1,23 @@ +Tuscany SCA for C++ Samples - Calculator Sample +=============================================== + +This is a very simple sample to show how an SCA composite can wire together +two components to implement a Calculator service and expose that service as +a Web Service. + +There are three sub projects in this workspace: + - sample.calculator + This contains the source code and SCDL artifacts for the SCA Calculator. + composite implementing the sample Calculator. + + - sample.calculator.client + A sample client which does a local call to the Calculator service. + + - sample.calculator.wsclient + A sample Axis2 Web Service client which calls the Calculator Web service. + +Additionally, there is the sample.calculator.solution.composite file. This +describes the configuration of the SCA Calculator composite deployed to the +SCA runtime. + +See the README.html file for instructions to build and run this sample diff --git a/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/README.html b/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/README.html new file mode 100644 index 0000000000..8a1198df46 --- /dev/null +++ b/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/README.html @@ -0,0 +1,254 @@ + +<!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 for C++ Samples - Calculator Sample</TITLE> +</HEAD> + +<BODY> +<DIV ID="bodyColumn"> + <DIV ID="contentBox"> + <DIV CLASS="section"> + <H2>Tuscany SCA for C++ Samples - Calculator Sample</H2> + + <P>This is a very simple sample to show how an SCA composite can wire + together two C++ components to implement a Calculator service and expose + that service as a Web Service. + </P> + <P>There are three sub projects in this workspace:</P> + <UL> + <LI>sample.calculator<BR/> + This contains the source code and SCDL artifacts for the SCA Calculator + composite implementing the sample Calculator. + </LI> + <LI>sample.calculator.client<BR/> + A sample client which does a local call to the Calculator service. + </LI> + <LI>sample.calculator.wsclient<BR/> + A sample Axis2 Web Service client which calls the Calculator Web service. + </LI> + </UL> + <P>Additionally, there is the sample.calculator.solution.composite file. This + describes the configuration of the SCA Calculator composite deployed to the SCA + runtime. + </P> + </DIV> + + <DIV CLASS="section"> + <H2>Contents</H2> + <OL> + <LI><A HREF="#linuxbld">Building the C++ samples on Linux</A></LI> + <LI><A HREF="#linuxrun">Running the Calculator sample on Linux:</A></LI> + <UL> + <LI><A HREF="#linuxbasic">Running the basic client</A></LI> + <LI><A HREF="#linuxws">Running the Web Service client</A></LI> + </UL> + <LI><A HREF="#winbld">Building the Calculator sample on Windows</A></LI> + <LI><A HREF="#winrun">Running the Calculator sample on Windows:</A></LI> + <UL> + <LI><A HREF="#winbasic">Running the basic client</A></LI> + <LI><A HREF="#winws">Running the Web Service client</A></LI> + </UL> + <LI><A HREF="#help">Getting help</A></LI> + </OL> + </DIV> + + + <DIV CLASS="section"> + <A NAME="linuxbld"><H2>Building the C++ samples on Linux</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</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> + <LI>AXIS2C_HOME=<path to axis2c version 0.94></LI> + </UL></LI> + </LI> + <LI>Build the C++ samples with the following command sequence: + <UL> + <LI>cd <tuscany_sca_install_dir>/samples</LI> + <LI>./configure --prefix=$TUSCANY_SCACPP --enable-static=no</LI> + <LI>make</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/Calculator</LI> + </OL> + </DIV> + + <DIV CLASS="section"> + <A NAME="linuxrun"><H2>Running the Calculator sample on Linux</H2></A> + <A NAME="linuxbasic"><H3>Calculator with basic client</H3></A> + <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> + <LI>AXIS2C_HOME=<path to axis2c version 0.92></LI> + </UL> + </LI> + <LI>Run the sample with the following commands: + <UL> + <LI>cd <tuscany_sca_install_dir>/samples/Calculator/deploy/sample.calculator.client</LI> + <LI>./runclient.sh</LI> + </UL> + </LI> + </OL> + <A NAME="linuxws"><H3>Calculator with Web Service client</H3></A> + <OL> + <LI>Ensure you have enabled Axis2C to run Tuscany SCA services. Follow the instructions + found <A HREF="../../doc/Axis2CWSService.html">here</A>. + </LI> + <LI>Start the Axis2C simple http server: + <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> + <LI>AXIS2C_HOME=<path to axis2c version 0.94></LI> + </UL> + </LI> + <LI>cd <tuscany_sca_install_dir>/samples/Calculator/deploy/sample.calculator + </LI> + <LI>./runwsserver.sh</LI> + </OL> + </LI> + <LI>Run the client: + <OL> + <LI>The following environment variable is required: + <UL> + <LI>AXIS2C_HOME=<path to axis2c version 0.94></LI> + </UL> + </LI> + <LI>cd <tuscany_sca_install_dir>/samples/Calculator/deploy/sample.calculator.wsclient</LI> + <LI>./runwsclient.sh</LI> + </OL> + </LI> + </OL> + </DIV> + + <DIV CLASS="section"> + <A NAME="winbld"><H2>Building the Calculator 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> + <LI>AXIS2C_HOME=<path to axis2c version 0.94></LI> + </UL></LI> + </LI> + <LI>You must have set up the environment for Microsoft Visual C++ tools. + The build command will call vcvars32 to set the environment. Ensure the + directory containing this is on your path. This will be where you + installed the compiler. + </LI> + <LI>Build the source, either via the Visual Studio 6 or 7 projects under + <tuscany_sca_install_dir>\samples\ides or via the command-line build file + found at <tuscany_sca_install_dir>\samples\ides\devstudio6\projects\Calculator\build.cmd + which will build and deploy the samples. + </LI> + </OL> + </DIV> + + <DIV CLASS="section"> + <A NAME="winrun"><H2>Running the Calculator sample on Windows</H2></A> + <A NAME="winbasic"><H3>Calculator with basic client</H3></A> + <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> + <LI>AXIS2C_HOME=<path to axis2c version 0.94></LI> + </UL> + </LI> + <LI>Run the sample with the following commands: + <UL> + <LI>cd <tuscany_sca_install_dir>\samples\Calculator\deploy\sample.calculator.client</LI> + <LI>runclient.bat</LI> + </UL> + </LI> + </OL> + <A NAME="winws"><H3>Calculator with Web Service client</H3></A> + <OL> + <LI>Ensure you have enabled Axis2C to run Tuscany SCA services. Follow the instructions + found <A HREF="../../doc/Axis2CWSService.html">here</A>. + </LI> + <LI>Start the Axis2C simple http server: + <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> + <LI>AXIS2C_HOME=<path to axis2c version 0.94></LI> + </UL> + </LI> + <LI>cd <tuscany_sca_install_dir>\samples\Calculator\deploy\sample.calculator</LI> + <LI>runwsserver.bat</LI> + </OL> + </LI> + <LI>Run the client: + <OL> + <LI>The following environment variable is required: + <UL> + <LI>AXIS2C_HOME=<path to axis2c version 0.94></LI> + </UL> + </LI> + <LI>cd <tuscany_sca_install_dir>\samples\Calculator\deploy\sample.calculator.wsclient</LI> + <LI>runwsclient.bat</LI> + </OL> + </LI> + </OL> + </DIV> + + + + <DIV CLASS="section"> + <A NAME="help"><H2>Getting Help</H2></A> + + <P>First place to look is at the Tuscany FAQ at + <A HREF="http://incubator.apache.org/tuscany/faq.html" + TARGET="_blank">http://incubator.apache.org/tuscany/faq.html</A> </P> + + <P>Any problem with this release can be reported to the Tuscany + <A HREF="http://incubator.apache.org/tuscany/mail-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/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/deploy.bat b/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/deploy.bat new file mode 100644 index 0000000000..efd18e8219 --- /dev/null +++ b/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/deploy.bat @@ -0,0 +1,67 @@ +@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. + +rem Will copy the correct files from the source tree for packaging and deployment of the +rem SCA Calculator sample. + +setlocal + +if . == .%1 ( +echo source path not specified +goto usage +) +set srcdir=%1 + +if . == .%2 ( +echo input directory not specified +goto usage +) +set inpath=%2 +echo %inpath% + +set package=sample.calculator + +set deploydir=%TUSCANY_SCACPP% +set samplesdir=%deploydir%\samples +set calcdir=%samplesdir%\Calculator +set calcdeploydir=%calcdir%\deploy +set samplecalc=%calcdeploydir%\%package% + +if not exist %samplesdir% mkdir %samplesdir% +if not exist %calcdir% mkdir %calcdir% +if not exist %calcdeploydir% mkdir %calcdeploydir% +if not exist %samplecalc% mkdir %samplecalc% + +set samplecalcsrc=%srcdir%\%package% +copy %srcdir%\%package%.solution.composite %calcdeploydir% +copy %samplecalcsrc%\*.wsdl %samplecalc% +copy %samplecalcsrc%\*.composite %samplecalc% +copy %samplecalcsrc%\*.componentType %samplecalc% +copy %samplecalcsrc%\runwsserver.bat %samplecalc% + +set library=Calculator +copy %inpath%\%library%.dll %samplecalc% + +if exist %inpath%\%library%.pdb copy %inpath%\%library%.pdb %samplecalc% + +goto end +:usage +echo Usage: deploy <sample-src> <build-output> +:end + +endlocal diff --git a/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/deployclient.bat b/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/deployclient.bat new file mode 100644 index 0000000000..bf4fd47d43 --- /dev/null +++ b/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/deployclient.bat @@ -0,0 +1,63 @@ +@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. + +rem Will copy the correct files from the source tree for packaging and deployment of the +rem SCA Calculator sample. + +setlocal + +if . == .%1 ( +echo source path not specified +goto usage +) +set srcdir=%1 + +if . == .%2 ( +echo input directory not specified +goto usage +) +set inpath=%2 +echo %inpath% + +set package=sample.calculator.client + +set deploydir=%TUSCANY_SCACPP% +set samplesdir=%deploydir%\samples +set calcdir=%samplesdir%\Calculator +set calcdeploydir=%calcdir%\deploy +set clientdir=%calcdeploydir%\%package% + +if not exist %samplesdir% mkdir %samplesdir% +if not exist %calcdir% mkdir %calcdir% +if not exist %calcdeploydir% mkdir %calcdeploydir% +if not exist %clientdir% mkdir %clientdir% + +set clientdirsrc=%srcdir%\%package% +copy %clientdirsrc%\runclient.bat %clientdir% + +set library=calculator_client +copy %inpath%\%library%.exe %clientdir% + +if exist %inpath%\%library%.pdb copy %inpath%\%library%.pdb %clientdir% + +goto end +:usage +echo Usage: deploy <sample-src> <build-output> +:end + +endlocal diff --git a/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/deploywsclient.bat b/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/deploywsclient.bat new file mode 100644 index 0000000000..8b1b1a53c5 --- /dev/null +++ b/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/deploywsclient.bat @@ -0,0 +1,63 @@ +@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. + +rem Will copy the correct files from the source tree for packaging and deployment of the +rem SCA Calculator sample. + +setlocal + +if . == .%1 ( +echo source path not specified +goto usage +) +set srcdir=%1 + +if . == .%2 ( +echo input directory not specified +goto usage +) +set inpath=%2 +echo %inpath% + +set package=sample.calculator.wsclient + +set deploydir=%TUSCANY_SCACPP% +set samplesdir=%deploydir%\samples +set calcdir=%samplesdir%\Calculator +set calcdeploydir=%calcdir%\deploy +set clientdir=%calcdeploydir%\%package% + +if not exist %samplesdir% mkdir %samplesdir% +if not exist %calcdir% mkdir %calcdir% +if not exist %calcdeploydir% mkdir %calcdeploydir% +if not exist %clientdir% mkdir %clientdir% + +set clientdirsrc=%srcdir%\%package% +copy %clientdirsrc%\runwsclient.bat %clientdir% + +set library=calculator_wsclient +copy %inpath%\%library%.exe %clientdir% + +if exist %inpath%\%library%.pdb copy %inpath%\%library%.pdb %clientdir% + +goto end +:usage +echo Usage: deploy <sample-src> <build-output> +:end + +endlocal diff --git a/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator.client/CalculatorClient.cpp b/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator.client/CalculatorClient.cpp new file mode 100644 index 0000000000..9ec8b04bd1 --- /dev/null +++ b/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator.client/CalculatorClient.cpp @@ -0,0 +1,160 @@ +/* + * 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. + */ + +/* $Rev$ $Date$ */ + +#include "Calculator.h" + +#include "osoa/sca/sca.h" +using namespace osoa::sca; + +#include "tuscany/sca/core/TuscanyRuntime.h" +using namespace tuscany::sca; + +#include <iostream> +#include <stdlib.h> +using namespace std; + + +void usage(); +bool IsNumber(const char *p); + +int main(int argc, char* argv[]) +{ + const char *operation; + float arg1 = 0; + float arg2 = 0; + + if (argc == 4) + { + operation = argv[1]; + + if (!IsNumber(argv[2])) + { + cout << "calculator_client: Argument 1 is not a number" << endl; + usage(); + } + else + { + arg1 = atof(argv[2]); + } + + if (!IsNumber(argv[3])) + { + cout << "calculator_client: Argument 2 is not a number" << endl; + usage(); + } + else + { + arg2 = atof(argv[3]); + } + } + else + { + usage(); + } + + try + { + // Locate a service + CompositeContext myContext = CompositeContext::getCurrent(); + Calculator *calcService = (Calculator*) myContext.locateService("CalculatorComponent/CalculatorService"); + if (calcService == 0) + { + cout << "calculator_client: Unable to find Calculator service" << endl; + } + else + { + try + { + float result = 0; + if (strcmp(operation, "add") == 0) + { + result = calcService->add(arg1, arg2); + cout << "calculator_client: add(" << arg1 << "," << arg2 << ") = " << result << endl; + } + else + if (strcmp(operation, "sub") == 0) + { + result = calcService->sub(arg1, arg2); + cout << "calculator_client: sub(" << arg1 << "," << arg2 << ") = " << result << endl; + } + else + if (strcmp(operation, "mul") == 0) + { + result = calcService->mul(arg1, arg2); + cout << "calculator_client: mul(" << arg1 << "," << arg2 << ") = " << result << endl; + } + else + if (strcmp(operation, "div") == 0) + { + result = calcService->div(arg1, arg2); + cout << "calculator_client: div(" << arg1 << "," << arg2 << ") = " << result << endl; + } + else + { + cout << "calculator_client: Unrecognized operation: " << operation << endl; + } + } + catch (char* x) + { + cout << "calculator_client: exception caught: " << x << endl; + } + } + + } + catch (ServiceRuntimeException& ex) + { + cout << ex << endl; + } + return 0; +} + +void usage() +{ + cout << "Usage: calculator_client add|sub|mul|div arg1 arg2" << endl; + exit(1); +} + +bool IsNumber (const char *p) +{ + int len = strlen(p); + int pointcount = 0; + + if (!isdigit (p[0]) && p[0] != '-' && p[0] != '+') + { + return false; + } + for (int i = 1; i < len; i++) + { + if (!isdigit (p[i])) + { + if (p[i] == '.') + { + if (pointcount > 0) return false; + pointcount++; + } + else + { + return false; + } + } + } + return true; +} diff --git a/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator.client/Makefile.am b/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator.client/Makefile.am new file mode 100644 index 0000000000..ced28cf042 --- /dev/null +++ b/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator.client/Makefile.am @@ -0,0 +1,55 @@ +# 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)/samples/Calculator/deploy +clientdir=$(deploydir)/sample.calculator.client + +client_PROGRAMS = calculator_client +client_SCRIPTS = runclient.sh +EXTRA_DIST = runclient.sh + +AM_CPPFLAGS = $(CPPFLAGS) +calculator_client_SOURCES = \ +CalculatorClient.cpp + +calculator_client_LDADD = \ +-L${TUSCANY_SCACPP}/lib \ + -ltuscany_sca \ +-L${TUSCANY_SCACPP}/extensions/cpp/lib \ + -ltuscany_sca_cpp \ +-L${TUSCANY_SDOCPP}/lib \ + -ltuscany_sdo \ + -ltuscany_sdo_axiom \ +-L$(AXIS2C_HOME)/lib \ + -laxis2_util \ + -laxis2_axiom \ + -laxis2_wsdl \ + -laxis2_engine \ + -lwoden \ + -lwoden_wsdl \ + -laxis2_xml_schema \ + -laxis2_parser \ + -laxis2_minizip \ + -lpthread \ + -laxis2_http_sender \ + -laxis2_http_receiver + +INCLUDES = \ +-I$(TUSCANY_SCACPP)/extensions/cpp/include \ +-I${TUSCANY_SCACPP}/include \ +-I${TUSCANY_SDOCPP}/include \ +-I../sample.calculator diff --git a/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator.client/runclient.bat b/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator.client/runclient.bat new file mode 100644 index 0000000000..f4308ff739 --- /dev/null +++ b/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator.client/runclient.bat @@ -0,0 +1,48 @@ +@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 TUSCANY_SCACPP_SYSTEM_ROOT=%~d0%~p0\..\ +set TUSCANY_SCACPP_DEFAULT_COMPONENT=sample.calculator.CalculatorComponent + +set PATH=%TUSCANY_SCACPP%\bin;%TUSCANY_SCACPP%\extensions\cpp\bin;%TUSCANY_SDOCPP%\bin;%AXIS2C_HOME%\lib;%PATH% + +.\calculator_client.exe div 5 2 + +:end +endlocal diff --git a/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator.client/runclient.sh b/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator.client/runclient.sh new file mode 100755 index 0000000000..ec4b3bb643 --- /dev/null +++ b/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator.client/runclient.sh @@ -0,0 +1,47 @@ +#!/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" + +TEST_SYSTEM=$APFULLDIR/../ + +export LD_LIBRARY_PATH=$TUSCANY_SCACPP/lib:$TUSCANY_SCACPP/extensions/cpp/lib:$TUSCANY_SDOCPP/lib:$AXIS2C_HOME/lib:$LD_LIBRARY_PATH + +export TUSCANY_SCACPP_SYSTEM_ROOT=$TEST_SYSTEM +export TUSCANY_SCACPP_DEFAULT_COMPONENT=sample.calculator.CalculatorComponent + +./calculator_client div 5 2 diff --git a/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator.solution.composite b/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator.solution.composite new file mode 100644 index 0000000000..0445d645e4 --- /dev/null +++ b/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator.solution.composite @@ -0,0 +1,29 @@ +<?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.calculator.solution"> + + <component name="sample.calculator.CalculatorComponent"> + <implementation.composite name="sample.calculator" /> + </component> + +</composite> + diff --git a/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator.wsclient/CalculatorWSClient.cpp b/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator.wsclient/CalculatorWSClient.cpp new file mode 100644 index 0000000000..267baf1722 --- /dev/null +++ b/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator.wsclient/CalculatorWSClient.cpp @@ -0,0 +1,186 @@ +/* + * 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. + */ + +/* $Rev$ $Date$ */ + +#include "axis2_Calculator_stub.h" +#include <stdio.h> +#include <axiom.h> +#include <axis2_util.h> +#include <axiom_soap.h> +#include <axis2_client.h> + +axiom_node_t * +build_om_programatically(const axis2_env_t *env, + const axis2_char_t *operation, + const axis2_char_t *param1, + const axis2_char_t *param2); + +int main(int argc, char** argv) +{ + axis2_stub_t *stub = NULL; + axiom_node_t *node = NULL; + axis2_status_t status = AXIS2_FAILURE; + const axis2_env_t *env = NULL; + const axis2_char_t *address = NULL; + const axis2_char_t *client_home = NULL; + axiom_node_t *ret_node = NULL; + + const axis2_char_t *operation = "add"; + const axis2_char_t *param1 = "40"; + const axis2_char_t *param2 = "8"; + + env = axis2_env_create_all( "CalculatorService_blocking.log", AXIS2_LOG_LEVEL_TRACE); + + client_home = AXIS2_GETENV("AXIS2C_HOME"); + if (!client_home) + client_home = "../../deploy"; + + address = "http://localhost:9090/axis2/services/CalculatorService"; + if (argc > 1 ) + operation = argv[1]; + if (AXIS2_STRCMP(operation, "-h") == 0) + { + printf("Usage : %s [operation] [param1] [param2] [endpoint_url]\n", argv[0]); + printf("use -h for help\n"); + printf("default operation add\n"); + printf("default param1 %s\n", param1); + printf("default param2 %s\n", param2); + printf("default endpoint_url %s\n", address); + printf("NOTE: command line arguments must appear in given order, with trailing ones being optional\n"); + return 0; + } + if (argc > 2 ) + param1 = argv[2]; + if (argc > 3 ) + param2 = argv[3]; + if (argc > 4 ) + address = argv[4]; + + printf ("Using endpoint : %s\n", address); + printf ("\nInvoking operation %s with params %s and %s\n", operation, param1, param2); + + node = build_om_programatically(env, operation, param1, param2); + stub = + axis2_Calculator_stub_create_with_endpoint_uri_and_client_home(env, address, client_home); + /* create node and invoke Calculator */ + ret_node = axis2_Calculator_stub_add(stub, env, node); + if(ret_node) + { + axis2_char_t *om_str = NULL; + om_str = AXIOM_NODE_TO_STRING(ret_node, env); + if(om_str) + { + printf("\nOM returned = %s\n", om_str); + } + + if (AXIOM_NODE_GET_NODE_TYPE(ret_node, env) == AXIOM_ELEMENT) + { + axis2_char_t *result = NULL; + axiom_node_t *result_node = (axiom_node_t*)AXIOM_NODE_GET_FIRST_CHILD(ret_node, env); + axiom_element_t *data_ele = (axiom_element_t*)AXIOM_NODE_GET_DATA_ELEMENT(result_node, env); + + result = AXIOM_ELEMENT_GET_TEXT(data_ele, env, result_node); + printf( "\nResult = %s\n", result); + } + else + { + axiom_xml_writer_t *writer = NULL; + axiom_output_t *om_output = NULL; + axis2_char_t *buffer = NULL; + writer = axiom_xml_writer_create_for_memory(env, NULL, AXIS2_TRUE, 0, + AXIS2_XML_PARSER_TYPE_BUFFER); + om_output = axiom_output_create (env, writer); + + AXIOM_NODE_SERIALIZE (ret_node, env, om_output); + buffer = (axis2_char_t*)AXIOM_XML_WRITER_GET_XML(writer, env); + printf ("\nReceived invalid OM as result : %s\n", buffer); + if(NULL != buffer) + { + AXIS2_FREE(env->allocator, buffer); + buffer = NULL; + } + if(NULL != om_output) + { + AXIOM_OUTPUT_FREE(om_output, env); + om_output = NULL; + } + } + } + else + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Stub invoke FAILED: Error code:" + " %d :: %s", env->error->error_number, + AXIS2_ERROR_GET_MESSAGE(env->error)); + printf("Calculator stub invoke FAILED!\n"); + } + if (stub) + { + AXIS2_STUB_FREE(stub, env); + } + return status; +} + +axiom_node_t * +build_om_programatically(const axis2_env_t *env, + const axis2_char_t *operation, + const axis2_char_t *param1, + const axis2_char_t *param2) +{ + axiom_node_t *Calculator_om_node = NULL; + axiom_element_t* Calculator_om_ele = NULL; + axiom_node_t* text_om_node = NULL; + axiom_element_t * text_om_ele = NULL; + axiom_namespace_t *ns1 = NULL; + + + axiom_xml_writer_t *xml_writer = NULL; + axiom_output_t *om_output = NULL; + axis2_char_t *buffer = NULL; + + ns1 = axiom_namespace_create (env, "http://sample/calculator", "ns1"); + + Calculator_om_ele = axiom_element_create(env, NULL, operation, ns1, &Calculator_om_node); + + text_om_ele = axiom_element_create(env, Calculator_om_node, "param1", NULL, &text_om_node); + AXIOM_ELEMENT_SET_TEXT(text_om_ele, env, param1, text_om_node); + + text_om_ele = axiom_element_create(env, Calculator_om_node, "param2", NULL, &text_om_node); + AXIOM_ELEMENT_SET_TEXT(text_om_ele, env, param2, text_om_node); + + xml_writer = axiom_xml_writer_create_for_memory(env, NULL, AXIS2_FALSE, AXIS2_FALSE, + AXIS2_XML_PARSER_TYPE_BUFFER); + om_output = axiom_output_create( env, xml_writer); + + AXIOM_NODE_SERIALIZE(Calculator_om_node, env, om_output); + buffer = (axis2_char_t*)AXIOM_XML_WRITER_GET_XML(xml_writer, env); + AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "\nSending OM node in XML : %s \n", buffer); + if(NULL != buffer) + { + AXIS2_FREE(env->allocator, buffer); + buffer = NULL; + } + if(NULL != om_output) + { + AXIOM_OUTPUT_FREE(om_output, env); + om_output = NULL; + } + + return Calculator_om_node; +} diff --git a/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator.wsclient/Makefile.am b/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator.wsclient/Makefile.am new file mode 100644 index 0000000000..5d0af5df1f --- /dev/null +++ b/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator.wsclient/Makefile.am @@ -0,0 +1,48 @@ +# 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)/samples/Calculator/deploy +wsclientdir=$(deploydir)/sample.calculator.wsclient + +wsclient_PROGRAMS = calculator_wsclient +wsclient_SCRIPTS = runwsclient.sh +EXTRA_DIST = runwsclient.sh + +AM_CPPFLAGS = $(CPPFLAGS) + +calculator_wsclient_SOURCES = \ +axis2_Calculator_stub.cpp \ +CalculatorWSClient.cpp + +noinst_HEADERS = *.h + +calculator_wsclient_LDADD = \ +-L$(AXIS2C_HOME)/lib \ + -laxis2_util \ + -laxis2_axiom \ + -laxis2_wsdl \ + -laxis2_engine \ + -lwoden \ + -lwoden_wsdl \ + -laxis2_xml_schema \ + -laxis2_parser \ + -laxis2_minizip \ + -lpthread \ + -laxis2_http_sender \ + -laxis2_http_receiver + +INCLUDES = -I${AXIS2C_HOME}/include diff --git a/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator.wsclient/axis2_Calculator_stub.cpp b/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator.wsclient/axis2_Calculator_stub.cpp new file mode 100644 index 0000000000..a24a3c9ed6 --- /dev/null +++ b/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator.wsclient/axis2_Calculator_stub.cpp @@ -0,0 +1,178 @@ +/* + * 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. + */ + +/* $Rev$ $Date$ */ + +#include "axis2_Calculator_stub.h" + + +axis2_stub_t * +axis2_Calculator_stub_create_with_endpoint_ref_and_client_home(const axis2_env_t *env, + axis2_endpoint_ref_t *endpoint_ref, + axis2_char_t *client_home) +{ + axis2_stub_t *stub = NULL; + + AXIS2_ENV_CHECK(env, NULL); + + stub = (axis2_stub_t *) + axis2_stub_create_with_endpoint_ref_and_client_home(env, endpoint_ref, + client_home); + if(NULL == stub) + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_NO_MEMORY, (axis2_status_codes)AXIS2_FAILURE); + return NULL; + } + axis2_populate_axis_service( stub, env); + return stub; +} + +void axis2_populate_axis_service( axis2_stub_t* stub, const axis2_env_t *env) +{ + axis2_svc_client_t* svc_client = NULL; + axis2_qname_t *op_qname = NULL; + axis2_svc_t* svc = NULL; + axis2_op_t* op = NULL; + + /*Modifying the Service*/ + svc_client = AXIS2_STUB_GET_SVC_CLIENT (stub, env ); + svc = (axis2_svc_t*)AXIS2_SVC_CLIENT_GET_AXIS_SERVICE ( svc_client, env ); + + /*creating the operations*/ + + op_qname = axis2_qname_create(env,"add" , "", NULL); + op = axis2_op_create_with_qname(env, op_qname); + AXIS2_OP_SET_MSG_EXCHANGE_PATTERN(op, env, AXIS2_MEP_URI_OUT_IN); + AXIS2_SVC_ADD_OP(svc, env, op); + + op_qname = axis2_qname_create(env,"sub" , "", NULL); + op = axis2_op_create_with_qname(env, op_qname); + AXIS2_OP_SET_MSG_EXCHANGE_PATTERN(op, env, AXIS2_MEP_URI_OUT_IN); + AXIS2_SVC_ADD_OP(svc, env, op); + + op_qname = axis2_qname_create(env,"mul" , "", NULL); + op = axis2_op_create_with_qname(env, op_qname); + AXIS2_OP_SET_MSG_EXCHANGE_PATTERN(op, env, AXIS2_MEP_URI_OUT_IN); + AXIS2_SVC_ADD_OP(svc, env, op); + + op_qname = axis2_qname_create(env,"div" , "", NULL); + op = axis2_op_create_with_qname(env, op_qname); + AXIS2_OP_SET_MSG_EXCHANGE_PATTERN(op, env, AXIS2_MEP_URI_OUT_IN); + AXIS2_SVC_ADD_OP(svc, env, op); +} + +axis2_stub_t * +axis2_Calculator_stub_create_with_endpoint_uri_and_client_home(const axis2_env_t *env, + const axis2_char_t *endpoint_uri, + const axis2_char_t *client_home) +{ + axis2_stub_t *stub = NULL; + + AXIS2_ENV_CHECK(env, NULL); + + stub = (axis2_stub_t *) + axis2_stub_create_with_endpoint_uri_and_client_home(env, endpoint_uri, + client_home); + if(NULL == stub) + { + AXIS2_ERROR_SET(env->error, + AXIS2_ERROR_NO_MEMORY, (axis2_status_codes)AXIS2_FAILURE); + return NULL; + } + + axis2_populate_axis_service( stub, env); + + return stub; +} + +/***************************Function implementation****************************/ + +axiom_node_t * +axis2_Calculator_stub_add(axis2_stub_t *stub, + const axis2_env_t *env, + axiom_node_t *node) +{ + axis2_svc_client_t *svc_client = NULL; + axiom_node_t *ret_node = NULL; + axis2_qname_t *op_qname = NULL; + + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + svc_client = AXIS2_STUB_GET_SVC_CLIENT(stub, env); + op_qname = axis2_qname_create(env, "add" , "", NULL); + ret_node = AXIS2_SVC_CLIENT_SEND_RECEIVE_WITH_OP_QNAME( svc_client, env, op_qname, node); + + return ret_node; +} + +axiom_node_t * +axis2_Calculator_stub_sub(axis2_stub_t *stub, + const axis2_env_t *env, + axiom_node_t *node) +{ + axis2_svc_client_t *svc_client = NULL; + axiom_node_t *ret_node = NULL; + axis2_qname_t *op_qname = NULL; + + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + svc_client = AXIS2_STUB_GET_SVC_CLIENT(stub, env); + op_qname = axis2_qname_create(env, "sub" , "", NULL); + ret_node = AXIS2_SVC_CLIENT_SEND_RECEIVE_WITH_OP_QNAME( svc_client, env, op_qname, node); + + return ret_node; +} + +axiom_node_t * +axis2_Calculator_stub_mul(axis2_stub_t *stub, + const axis2_env_t *env, + axiom_node_t *node) +{ + axis2_svc_client_t *svc_client = NULL; + axiom_node_t *ret_node = NULL; + axis2_qname_t *op_qname = NULL; + + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + svc_client = AXIS2_STUB_GET_SVC_CLIENT(stub, env); + op_qname = axis2_qname_create(env, "mul" , "", NULL); + ret_node = AXIS2_SVC_CLIENT_SEND_RECEIVE_WITH_OP_QNAME( svc_client, env, op_qname, node); + + return ret_node; +} + +axiom_node_t * +axis2_Calculator_stub_div(axis2_stub_t *stub, + const axis2_env_t *env, + axiom_node_t *node) +{ + axis2_svc_client_t *svc_client = NULL; + axiom_node_t *ret_node = NULL; + axis2_qname_t *op_qname = NULL; + + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + svc_client = AXIS2_STUB_GET_SVC_CLIENT(stub, env); + op_qname = axis2_qname_create(env, "div" , "", NULL); + ret_node = AXIS2_SVC_CLIENT_SEND_RECEIVE_WITH_OP_QNAME( svc_client, env, op_qname, node); + + return ret_node; +} + diff --git a/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator.wsclient/axis2_Calculator_stub.h b/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator.wsclient/axis2_Calculator_stub.h new file mode 100644 index 0000000000..833c6f85c6 --- /dev/null +++ b/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator.wsclient/axis2_Calculator_stub.h @@ -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. + */ + +/* $Rev$ $Date$ */ + +#ifndef AXIS2_ECHO_STUB_H +#define AXIS2_ECHO_STUB_H + +/** + * @file axis2_Calculator_stub.h + * @brief axis2 Calculator stub interface + */ + +#include <axis2_stub.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + +axiom_node_t * +axis2_Calculator_stub_add(axis2_stub_t *stub, + const axis2_env_t *env, + axiom_node_t *node); + +axiom_node_t * +axis2_Calculator_stub_sub(axis2_stub_t *stub, + const axis2_env_t *env, + axiom_node_t *node); + +axiom_node_t * +axis2_Calculator_stub_mul(axis2_stub_t *stub, + const axis2_env_t *env, + axiom_node_t *node); + +axiom_node_t * +axis2_Calculator_stub_div(axis2_stub_t *stub, + const axis2_env_t *env, + axiom_node_t *node); +/** + * populate services + */ +void axis2_populate_axis_service( axis2_stub_t* stub, const axis2_env_t *env); + +/** + * Creates axis2_stub struct + * @param endpoint reference + * @return pointer to newly created axis2_stub struct + */ +axis2_stub_t * +axis2_Calculator_stub_create_with_endpoint_ref_and_client_home(const axis2_env_t *env, + axis2_endpoint_ref_t *endpoint_ref, + axis2_char_t *client_home); + +/** + * Creates axis2_stub struct + * @param endpoint uri + * @return pointer to newly created axis2_stub struct + */ +axis2_stub_t * +axis2_Calculator_stub_create_with_endpoint_uri_and_client_home(const axis2_env_t *env, + const axis2_char_t *endpoint_uri, + const axis2_char_t *client_home); +/** @} */ + +#ifdef __cplusplus +} +#endif +#endif /* AXIS2_ECHO_STUB_H */ diff --git a/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator.wsclient/runwsclient.bat b/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator.wsclient/runwsclient.bat new file mode 100644 index 0000000000..6d50f23370 --- /dev/null +++ b/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator.wsclient/runwsclient.bat @@ -0,0 +1,32 @@ +@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 "%AXIS2C_HOME%" == "" ( +echo "AXIS2C_HOME not set" +goto end +) +echo Using Axis2C installed at %AXIS2C_HOME%" + +rem Run the client +.\calculator_wsclient.exe div 5 2 + +:end +endlocal diff --git a/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator.wsclient/runwsclient.sh b/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator.wsclient/runwsclient.sh new file mode 100755 index 0000000000..51d8dbac22 --- /dev/null +++ b/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator.wsclient/runwsclient.sh @@ -0,0 +1,30 @@ +#!/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$AXIS2C_HOME = x ]; then +echo "AXIS2C_HOME not set" +exit; +fi +echo "Using Axis2C installed at $AXIS2C_HOME" + +export LD_LIBRARY_PATH=$AXIS2C_HOME/lib:$LD_LIBRARY_PATH + +./calculator_wsclient div 5 2 diff --git a/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator/Calculator.h b/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator/Calculator.h new file mode 100644 index 0000000000..1a88c9cb67 --- /dev/null +++ b/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator/Calculator.h @@ -0,0 +1,36 @@ +/* + * 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. + */ + +/* $Rev$ $Date$ */ + +#ifndef sample_calculator_h +#define sample_calculator_h + +class Calculator +{ +public: + virtual float add(float arg1, float arg2) = 0; + virtual float sub(float arg1, float arg2) = 0; + virtual float mul(float arg1, float arg2) = 0; + virtual float div(float arg1, float arg2) = 0; +}; + +#endif // sample_calculator_h + + diff --git a/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator/Calculator.wsdl b/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator/Calculator.wsdl new file mode 100644 index 0000000000..37529c06c5 --- /dev/null +++ b/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator/Calculator.wsdl @@ -0,0 +1,161 @@ +<?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. +--> + +<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" + xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" + xmlns:xs="http://www.w3.org/2001/XMLSchema" + xmlns:tns="http://sample/calculator" + targetNamespace="http://sample/calculator"> + <types> + <xs:schema targetNamespace="http://sample/calculator" + xmlns:xs="http://www.w3.org/2001/XMLSchema" + xmlns:tns="http://sample/calculator" elementFormDefault="qualified"> + + <xs:element name="add"> + <xs:complexType> + <xs:sequence> + <xs:element name="param1" type="xs:float"/> + <xs:element name="param2" type="xs:float"/> + </xs:sequence> + </xs:complexType> + </xs:element> + + <xs:element name="sub"> + <xs:complexType> + <xs:sequence> + <xs:element name="param1" type="xs:float"/> + <xs:element name="param2" type="xs:float"/> + </xs:sequence> + </xs:complexType> + </xs:element> + + <xs:element name="mul"> + <xs:complexType> + <xs:sequence> + <xs:element name="param1" type="xs:float"/> + <xs:element name="param2" type="xs:float"/> + </xs:sequence> + </xs:complexType> + </xs:element> + + <xs:element name="div"> + <xs:complexType> + <xs:sequence> + <xs:element name="param1" type="xs:float"/> + <xs:element name="param2" type="xs:float"/> + </xs:sequence> + </xs:complexType> + </xs:element> + + <xs:element name="result"> + <xs:complexType> + <xs:sequence> + <xs:element name="data" type="xs:float"/> + </xs:sequence> + </xs:complexType> + </xs:element> + + </xs:schema> + </types> + + <message name="addRequestMsg"> + <part name="body" element="tns:add" /> + </message> + <message name="subRequestMsg"> + <part name="body" element="tns:sub" /> + </message> + <message name="mulRequestMsg"> + <part name="body" element="tns:mul" /> + </message> + <message name="divRequestMsg"> + <part name="body" element="tns:div" /> + </message> + + <message name="calculatorResponseMsg"> + <part name="body" element="tns:result" /> + </message> + + <portType name="Calculator"> + <operation name="add"> + <input message="tns:addRequestMsg" /> + <output message="tns:calculatorResponseMsg" /> + </operation> + <operation name="sub"> + <input message="tns:subRequestMsg" /> + <output message="tns:calculatorResponseMsg" /> + </operation> + <operation name="mul"> + <input message="tns:mulRequestMsg" /> + <output message="tns:calculatorResponseMsg" /> + </operation> + <operation name="div"> + <input message="tns:divRequestMsg" /> + <output message="tns:calculatorResponseMsg" /> + </operation> + </portType> + + <binding name="CalculatorBinding" + type="tns:Calculator"> + <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" /> + <operation name="add"> + <soap:operation soapAction="CalculatorService#add" /> + <input> + <soap:body use="literal" /> + </input> + <output> + <soap:body use="literal" /> + </output> + </operation> + <operation name="sub"> + <soap:operation soapAction="CalculatorService#sub" /> + <input> + <soap:body use="literal" /> + </input> + <output> + <soap:body use="literal" /> + </output> + </operation> + <operation name="mul"> + <soap:operation soapAction="CalculatorService#mul" /> + <input> + <soap:body use="literal" /> + </input> + <output> + <soap:body use="literal" /> + </output> + </operation> + <operation name="div"> + <soap:operation soapAction="CalculatorService#div" /> + <input> + <soap:body use="literal" /> + </input> + <output> + <soap:body use="literal" /> + </output> + </operation> + </binding> + + <service name="CalculatorService"> + <port name="CalculatorPort" + binding="tns:CalculatorBinding"> + <soap:address location="http://localhost:9090/axis2/services/CalculatorService" /> + </port> + </service> +</definitions> diff --git a/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator/CalculatorImpl.componentType b/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator/CalculatorImpl.componentType new file mode 100644 index 0000000000..72fe9842e8 --- /dev/null +++ b/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator/CalculatorImpl.componentType @@ -0,0 +1,31 @@ +<?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. +--> + +<componentType xmlns="http://www.osoa.org/xmlns/sca/1.0"> + + <service name="CalculatorService"> + <interface.cpp header="Calculator.h"/> + </service> + + <reference name="divideService"> + <interface.cpp header="Divide.h"/> + </reference> + +</componentType>
\ No newline at end of file diff --git a/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator/CalculatorImpl.cpp b/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator/CalculatorImpl.cpp new file mode 100644 index 0000000000..73abf2f1df --- /dev/null +++ b/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator/CalculatorImpl.cpp @@ -0,0 +1,89 @@ +/* + * 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. + */ + +/* $Rev$ $Date$ */ + +#include "CalculatorImpl.h" +#include <stdio.h> + +#include "Divide.h" +#include "osoa/sca/ComponentContext.h" +#include "osoa/sca/ServiceRuntimeException.h" + +CalculatorImpl::CalculatorImpl() +{ +} + +CalculatorImpl::~CalculatorImpl() +{ +} + +// Calculator interface +float CalculatorImpl::add(float arg1, float arg2) +{ + float result = arg1 + arg2; + + printf("CalculatorImpl::add %f + %f = %f\n", arg1, arg2, result); + return result; +} + +float CalculatorImpl::sub(float arg1, float arg2) +{ + float result = arg1 - arg2; + printf("CalculatorImpl::sub %f - %f = %f\n", arg1, arg2, result); + return result; +} + +float CalculatorImpl::mul(float arg1, float arg2) +{ + float result = arg1 * arg2; + printf("CalculatorImpl::mul %f * %f = %f\n", arg1, arg2, result); + return result; +} + +float CalculatorImpl::div(float arg1, float arg2) +{ + float result = 0; + + // This method shows how to invoke a service on a different component from within a component + + // First, get the current ComponentContext + osoa::sca::ComponentContext myContext = osoa::sca::ComponentContext::getCurrent(); + + try + { + // Find the required service, as referenced in CalculatorImpl.componentType + Divide* divideService = (Divide*)myContext.getService("divideService"); + + // Finally, invoke the service + result = divideService->divide(arg1, arg2); + + printf("CalculatorImpl::div Divide returned result: %f\n", result); + + } + catch (osoa::sca::ServiceRuntimeException& e) + { + // Print out error message and carry on + printf("CalculatorImpl::div Error whilst invoking Divide: %s", e.getMessageText()); + } + + return result; +} + + diff --git a/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator/CalculatorImpl.h b/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator/CalculatorImpl.h new file mode 100644 index 0000000000..af8a5eeab1 --- /dev/null +++ b/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator/CalculatorImpl.h @@ -0,0 +1,41 @@ +/* + * 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. + */ + +/* $Rev$ $Date$ */ + +#ifndef sample_calculatorimpl_h +#define sample_calculatorimpl_h + +#include "Calculator.h" + +class CalculatorImpl : public Calculator +{ +public: + CalculatorImpl(); + virtual ~CalculatorImpl(); + + // Calculator interface + virtual float add(float arg1, float arg2); + virtual float sub(float arg1, float arg2); + virtual float mul(float arg1, float arg2); + virtual float div(float arg1, float arg2); +}; + +#endif // sample_calculatorimpl_h + diff --git a/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator/Divide.h b/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator/Divide.h new file mode 100644 index 0000000000..6e171ed733 --- /dev/null +++ b/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator/Divide.h @@ -0,0 +1,34 @@ +/* + * 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. + */ + +/* $Rev$ $Date$ */ + + +#ifndef sample_divide_h +#define sample_divide_h + +class Divide +{ +public: + virtual float divide(float arg1, float arg2) = 0; +}; + +#endif // sample_divide_h + + diff --git a/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator/DivideImpl.componentType b/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator/DivideImpl.componentType new file mode 100644 index 0000000000..d7369e3ff0 --- /dev/null +++ b/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator/DivideImpl.componentType @@ -0,0 +1,27 @@ +<?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. +--> + +<componentType xmlns="http://www.osoa.org/xmlns/sca/1.0"> + + <service name="DivideService"> + <interface.cpp header="Divide.h"/> + </service> + +</componentType> diff --git a/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator/DivideImpl.cpp b/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator/DivideImpl.cpp new file mode 100644 index 0000000000..8b9db46ecb --- /dev/null +++ b/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator/DivideImpl.cpp @@ -0,0 +1,47 @@ +/* + * 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. + */ + +/* $Rev$ $Date$ */ + +#include "DivideImpl.h" +#include <stdio.h> + +DivideImpl::DivideImpl() +{ +} + +DivideImpl::~DivideImpl() +{ +} + +// Divide interface +float DivideImpl::divide(float arg1, float arg2) +{ + if(arg2 == 0.0) + { + printf("DivideImpl::div %f / %f !! Cannot divide by zero, so returning 0\n", arg1, arg2); + return 0; + } + + float result = arg1 / arg2; + printf("DivideImpl::div %f / %f = %f\n", arg1, arg2, result); + return result; +} + + diff --git a/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator/DivideImpl.h b/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator/DivideImpl.h new file mode 100644 index 0000000000..64045f1899 --- /dev/null +++ b/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator/DivideImpl.h @@ -0,0 +1,39 @@ +/* + * 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. + */ + +/* $Rev$ $Date$ */ + + +#ifndef sample_divideimpl_h +#define sample_divideimpl_h + +#include "Divide.h" + +class DivideImpl : public Divide +{ +public: + DivideImpl(); + virtual ~DivideImpl(); + + // Divide interface + virtual float divide(float arg1, float arg2); +}; + +#endif // sample_divideimpl_h + diff --git a/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator/Makefile.am b/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator/Makefile.am new file mode 100644 index 0000000000..c57d0c9fe5 --- /dev/null +++ b/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator/Makefile.am @@ -0,0 +1,55 @@ +# 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)/samples/Calculator/deploy +compositedir=$(deploydir)/sample.calculator + +BUILT_SOURCES = scagen + +noinst_HEADERS = *.h + +scagen: + java -jar $(TUSCANY_SCACPP)/bin/scagen.jar -dir . -output . + +composite_SCRIPTS = runwsserver.sh + +composite_LTLIBRARIES = libCalculator.la +composite_DATA = *.composite *.componentType *.wsdl +EXTRA_DIST = *.composite *.componentType *.wsdl runwsserver.sh + +dist_libCalculator_la_SOURCES = \ +CalculatorImpl.cpp \ +DivideImpl.cpp + +nodist_libCalculator_la_SOURCES = \ +CalculatorImpl_CalculatorService_Proxy.cpp \ +CalculatorImpl_CalculatorService_Wrapper.cpp \ +CalculatorImpl_divideService_Proxy.cpp \ +DivideImpl_DivideService_Proxy.cpp \ +DivideImpl_DivideService_Wrapper.cpp + +libCalculator_la_LIBADD = \ +-L${TUSCANY_SCACPP}/lib \ + -ltuscany_sca \ +-L${TUSCANY_SCACPP}/extensions/cpp/lib \ + -ltuscany_sca_cpp + +INCLUDES = \ +-I$(TUSCANY_SCACPP)/extensions/cpp/include \ +-I$(TUSCANY_SCACPP)/include \ +-I${TUSCANY_SDOCPP}/include + diff --git a/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator/runwsserver.bat b/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator/runwsserver.bat new file mode 100644 index 0000000000..160152e6a9 --- /dev/null +++ b/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator/runwsserver.bat @@ -0,0 +1,49 @@ +@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 TUSCANY_SCACPP_SYSTEM_ROOT=%~d0%~p0\..\ +set TUSCANY_SCACPP_DEFAULT_COMPONENT=sample.calculator.CalculatorComponent + +set PATH=%TUSCANY_SCACPP%\bin;%TUSCANY_SCACPP%\extensions\cpp\bin;%TUSCANY_SDOCPP%\bin;%AXIS2C_HOME%\lib;%PATH% + +cd %AXIS2C_HOME%\bin +.\axis2_http_server.exe + +:end +endlocal diff --git a/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator/runwsserver.sh b/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator/runwsserver.sh new file mode 100755 index 0000000000..b94d841d66 --- /dev/null +++ b/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator/runwsserver.sh @@ -0,0 +1,48 @@ +#!/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" + +TEST_SYSTEM=$APFULLDIR/../ + +export LD_LIBRARY_PATH=$TUSCANY_SCACPP/lib:$TUSCANY_SCACPP/extensions/cpp/lib:$TUSCANY_SDOCPP/lib:$AXIS2C_HOME/lib:$LD_LIBRARY_PATH + +export TUSCANY_SCACPP_SYSTEM_ROOT=$TEST_SYSTEM +export TUSCANY_SCACPP_DEFAULT_COMPONENT=sample.calculator.CalculatorComponent + +cd $AXIS2C_HOME/bin +./axis2_http_server diff --git a/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator/sample.calculator.composite b/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator/sample.calculator.composite new file mode 100644 index 0000000000..ae4657b366 --- /dev/null +++ b/sca-cpp/tags/cpp-1.0-incubating-M2-final/sca/samples/Calculator/sample.calculator/sample.calculator.composite @@ -0,0 +1,39 @@ +<?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.calculator"> + + <service name="CalculatorService"> + <interface.wsdl interface="http://sample/calculator#wsdl.interface(Calculator)"/> + <binding.ws/> + <reference>CalculatorComponent/CalculatorService</reference> + </service> + + <component name="CalculatorComponent"> + <implementation.cpp library="Calculator" header="CalculatorImpl.h"/> + <reference name="divideService">DivideComponent/DivideService</reference> + </component> + + <component name="DivideComponent"> + <implementation.cpp library="Calculator" header="DivideImpl.h"/> + </component> + +</composite>
\ No newline at end of file |