Linear Systems Solver Service Example
This example shows you how to create a linear systems solver Web service.
An example demonstration client code is given as well. The service uses
dynamic arrays for vectors and matrices. Vectors and matrices are exchanged
in SOAP as partially transmitted arrays of double. This supports a simple
form of matrix sparsity (however, the linear systems solver algorithm is
a dense matrix solver). The service returns partially transmitted arrays
by eliminating initial and trailing zeros in vectors and matrices.
The Web service implements the following remote methods:
-
ludcmp: LU decomposition of a matrix
-
lubksb: backsubstitution for LU decomposition
-
lusol: LU-decomposition-based linear system solver
-
lusols: LU-decomposition-based solver of multiple linear systems
-
luinv: LU-decomposition-based matrix inversion
-
ludet: LU-decomposition-based matrix determinant
Generated WSDL service description.
Step 1: Write the Main Program
We wrote a linear systems solver service for you: click here
and select "File - Save As" from your browser's menu.
You also need a C++ library with vector and matrix classes: click
here.
To test your linear systems solver service, get a demonstration client
source code: click here.
Step 2: Generate the SOAP Stub Routines
The input to the SOAP C++ stub and skeleton compiler is a specification of the names of the
SOAP methods and the data structures given as
C/C++ declarations. You can get this header file specification here.
This header file is used to compile the linear systems solver service and
demonstration client.
Use the SOAP C/C++ stub and skeleton compiler to process the header
file:
soapcpp lu.h
Step 3: Compiling Your Service App
Compile the service sources. For example, in Linux the command to compile
would be:
g++ -o luserver.cgi luserver.cpp lumat.cpp soapC.cpp soapServer.cpp stdsoap2.cpp
Deploy the luserver.cgi executable as a CGI application in your
Web server.
Step 4: Compiling Your Demonstration Client App
Change the endpoint URL in the luclient.cpp source to your endpoint
URL for this service (the URL of your CGI application).
Compile the client sources. For example, in Linux the command to compile
would be:
g++ -o luclient luclient.cpp lumat.cpp soapC.cpp soapClient.cpp stdsoap2.cpp
Step 5: Try it Out
Execute the command "luclient".
Step 6: Alternative: Stand-Alone Service App
Compile the service as indicated in Step 3. Execute the command:
luserver.cgi "mymachine.mydomain.com" 18080 &
where "mymachine.mydomain.com" refers to the machine on which
the service is executed. Note that the service can run in the background.
Change the endpoint URL of the demonstration client luclient.cpp
to "mymachine.mydomain.com:18080" and recompile the client sources.
Execute the command "luclient", which will now be served by
the stand-alone service via your intranet directly over sockets.