getCount() and one to increment the counter: incrementCount()After the software is installed, there are several steps involved in making this demo. Idoox has several tools that will do a lot of the work for you. Idoox will marshall the data across the nextwork for each method call. In order to do that, you need to tell it what the data looks like. This works much like CORBA´s and DCOM´s IDL language. The language is called SCL.
SCL (SOAP Contract Language) used to be a proposal for a standard. but there were several competing proposals. The people proposing the competing standards have since combined their efforts and created a new proposal Web Services Description Language (WSDL).
Luckily, you don´t have to learn SCL nor WSDL. The Idoox tools will take a Java file, create an SCL file, and then create the Stubs and Skeletons. The following steps help you through this process:
.jar files into your classpath. These are:
Making a Java file
You need to make a .java file that corresponds to the methods and datat that will be used to communicate between the modules. The reason that you must make a Java file is that the tools only work on a Java file. Our simple example has only two methods and one data. The file looks like this:
public class Counter
{
private int count;
public int getCount()
{
return count;
}
public void incrementCount()
{
count++;
}
}
Making an SCL file from the Java .class file
After making your .java file (we´ll put it into the file Counter.java), you will want to use the Idoox tool to make the SCL file. To do this, first compile your .java file and then run the SCL compiler, like this:
javac Counter.java
The first parameter to Java2SCL is a namespace. You only need make this something unique. It isn't terribly important. It will only be used inside the XML documents.
java com.idoox.soap.Java2SCL dsl-cnt Counter > Counter.scl
For more information on the Idoox API, see
http://www.zvon.org/idooxoap/doc/api/
Making the stubs and skeleton from the SCL file
Now, we are ready to create the Stubs and Skeletons. The SCL compiler creates these C++ files from the SCL file like this:
java -Ddebug.config=none com.idoox.soap.SCLCompilerC -v -u Counter.scl Counter
Filling out the stub code
Now, you need to finish the stubs and skeletons that were created. First, the file CounterImpl.h needs to have the instance variable declarations added. The two lines indicated below are added:
class CounterImpl : public SOAP_ReferencedInterface {
Now, the file
private: // added
int m_iCount; // added
public:
CounterImpl();
virtual ~CounterImpl();
Kind getKind() const { return Implementation; };
DOMString getID() const { return "dsl-cnt#Counter"; };
int getCount ();
void incrementCount ();
};CounterImpl.cpp needs to have its stub code completed. The SCL compiler will make stub methods with comments that they need their bodies coded. We finish the methods as follows:
CounterImpl::CounterImpl() {;
m_iCount = 0;
}
CounterImpl::~CounterImpl() {;
// put the destruction code here - this can be left empty
}
int CounterImpl::getCount () {
return m_iCount;
}
void CounterImpl::incrementCount () {
m_iCount++;
}
Writing the server and the client code
We write the client program in file CounterClient.cpp.
And then we write the server program in file Server.cpp.
Compiling
The rest is normal programming; however, getting the libraries correct is a little complex. I´m not listing that yet until I can get it siplified.
You might (you definitely must for RedHat) need to set up your library path first, though. You should set this library to include the "lib" directory under your xerces install directory and to include the "build/lib" directory under your IdooXoap-C install directory.
In RedHat Linux with bash, set your library path with:
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:<xerces-c-install-dir>/lib:<IdooXoap-C-install-dir>/build/lib
For example,
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/pkgs/xerces-c/lib:/usr/local/src/IdooXoap-C/build/lib
Running the programs
Once the programs are made, start the server. The demo servers are all stand-alone servers (they do not require a Web Server to be running). Both the server and the client have a lot of debugging messages, so you might want to direct STDERR to /dev/null.
The server needs no parameters, so here's an example of starting the Structures demo server:
cd build/bin
Now you can run the client passing the URL of the server as the only parameter.
./CounterServer 2> /dev/null &
./Structures http://localhost:8080 2> /dev/null