summaryrefslogtreecommitdiffstats
path: root/cpp/sca/samples/PHPCalculator/README
blob: d91c95876382a69d784cb94d5b44641f609434d6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
Tuscany SCA for C++ Samples - PHP Calculator Sample
===================================================

This is a simple sample to show how an SCA composite can wire together
a number of components to implement a Calculator service and expose that service as
to a number of different tpyes of client. The sample components are implemented in various 
ways to demonstrate the different features of the PHP SCA extension.

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 PHP SCA Web Service client which calls the Calculator Web service.

Additionally, there is the sample.calculator.app.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 - TODO)

The file phpcalculator.png is a picture of the sample. Given the restrictions on the
current PHP extension (see TODOs in the PHP Extension README) some parts of this 
have not been tested yet. 

The path that has been tested is as follows:

Local CPP client -> CPP Calculator -> PHP Divide -> PHP Add ------> PHP Log
                                          |-------> PHP Subtract -> PHP Log
                                          |-------> PHP Multiple -> PHP Log
                                          |-------> PHP Divide ---> PHP Log

The local CPP client is used because
 - the work to enable PHP to host SCA is not done yet 
 - running with the axis service causes missing symbols errors on my box
 
The CPP Calculator component is used because
 - The local CPP client can only talk directly to a CPP component
               
To run the sample in this configuration use the CalculatorClient.cpp found in the 
sample.calculator.client directory

Windows
=======

Hasn't yet been tests on windows in this configuration so ignore the following

I use the following bat file to start the stand alone axis server and include 
appropriate references to PHP dependencies. This needs turning into a proper
run script but I haven't got to this yet

set TUSCANY_SCACPP_LOGGING=9
set AXIS2C_HOME=C:\axis2c-bin-0.95-win32
set PATH=%TUSCANY_SCACPP%\bin;%TUSCANY_SDOCPP%\bin;%TUSCANY_SCACPP%\extensions\php\bin;%AXIS2C_HOME%\lib;c:\libxml2-2.6.23.win32\bin;c:\apps\iconv-1.9.1.win32\bin;c:\apps\zlib-1.2.3.win32\bin;C:\php-5.2.0\
set TUSCANY_SCACPP_ROOT=%TUSCANY_SCACPP%\samples\PHPCalculator
rem set TUSCANY_SCACPP_DEFAULT_COMPONENT=sample.calculator.CalculatorComponent

%AXIS2C_HOME%\bin\axis2_http_server.exe -l 9                         

I then

cd %TUSCANY_SCACPP%\samples\PHPCalculator\samples.calculator.wsclient
runwsclient.bat

This has the effect of runing a PHP/SCA client (no C++ SCA content at all)
to generate a web service request to the C++ SCA runtime hosting the calculator
application.

Currently this doesn't run all the way through due to a WSDL bug in PHP SCA
(http://pecl.php.net/bugs/bug.php?id=9572). But it gets 99% of the way there. 
You will see the server doing all of its stuff and returning the correct result. 

Linux
=====

I find the following environment variables useful when running PHP embedded inside of
Tuscany SCA.

# the library path use to locate shared libraries
export LD_LIBRARY_PATH=$LIBXML2_LIB:\
$AXIS2C_HOME/lib:\
$PHP_LIB:\
$TUSCANY_SDOCPP/lib:\
$TUSCANY_SCACPP/lib:\
$TUSCANY_SCACPP/extensions/cpp/lib:\
$TUSCANY_SCACPP/extensions/php/lib:\
$TUSCANY_SCACPP/extensions/ws/lib:\
$TUSCANY_SCACPP/samples/PHPCalculator/deploy/sample.calculator:\
$PHP_SCA_SDO_LIB

# tell PHP specifically where to find php.ini rather than relying on the default
set PHPRC=/usr/local/lib

# tell Tuscany SCA which composite appplication to run
export TUSCANY_SCACPP_ROOT=/usr/local/tuscany/cpp/sca/deploy/samples/PHPCalculator

# tell Tuscany SCA which is the default component in this composite 
export TUSCANY_SCACPP_COMPONENT=sample.calculator.CalculatorComponent

# turn on logging so you can see what's going on
export TUSCANY_SCACPP_LOGGING=9

There is an env.sh file that can be edited and used to set your environment. One edited
to reflect your environment do:

source env.sh

The CPP client currently has an independent Makefile due to build problems with the automake
build on my box. If you have your environment configured as above you should be able to do:

make

This will produce a.out which can be run using the provided script.

runclient_cpp.sh