[greenstone-devel] Re: About writing a client to invoke service

From Anupama of Greenstone Team
DateTue Aug 19 12:36:57 2008
Subject [greenstone-devel] Re: About writing a client to invoke service
In-Reply-To (48A9B3B5-9070206-cis-strath-ac-uk)
Hi Suthanya,

1. The runtime errors:

I went through your Word document. When running it is still not finding
your jar files, it may not be finding any of them in fact even if it is
at present only throwing an exception about the first missing classes it
comes across.

Can you try the following:
On page 4 of your document you have 2 images.

The first one is of how you added jar files to your compile path in
NetBeans from its Compile Tab.

The second image is of how you added jar files to your runtime path from
the Run TESTS Tab.

However, there are also Compile TESTS and a Run Tab. Can you try adding
the jar files required during runtime into the Run Tab instead of the
Run Tests Tab? I'm not sure, but I think this may be the reason it still
couldn't find those jar files.

2. > and if I got GreenstoneConnection.class after i comply this file
> what the next step I should going on?

Try running it. First check you get some similar output.
(To run the client, you will need to have the QBRSOAPServer web services
deployed on your Greenstone site, which you have already done I
understand from your attachment. And your document also shows how your
deployed web services are located at

The aim of the exercise is to illustrate how to create a web service and
write a client for it. Do you understand how the communication works?
For instance, with the gs3democlient, you can move to another computer
from the one where you have Greenstone 3 installed with QBRSOAPServer
web services deployed, and on this second machine you can download and
run the democlient program and it should still work.

What you can do once you have got GreenstoneConnection working, is to
create a copy of it and rename it and change the code so that it works
with your new Username web service instead. Then your main method can
invoke that web service to print the output.

Once you get a feel for how the process works, you can use this as a
starting point to write the sort of web services you want, providing the
sort of methods you want (as opposed to the 'username' service). A set
of related web services in Java is just a class with normal methods.
Once you deploy them--as you did with the username service--they become
web services. For instance, someone may write a spell-checker that takes
a String of text and returns a String with xml markup to indicate
errors. If they find it useful, they could deploy this method as a 'web
service'. Except for the deployment step, the process is the same as
creating any other reusable class.

The client side will connect to the web services and invoke them when it
needs them. If you anticipate that others may want to use your web
services, you can write a class on the client side that provides
individual methods that invoke each of the corresponding web service
operations. Then you can call the methods of that intermediate
client-side class from other classes that actually need to use the web
services: they need only call the client-side class' methods as they
would any normal method, and forget all about how the underlying
operations are web services on a possibly remote computer.
Only that intermediate client-side class would have to worry about the
details of how to invoke a web service and about wsdl files, etc.

The above is what I did with the GS3democlient:
1. the QBRSOAPServer.java is the web services class
2. The classes in
are the classes that know about invoking web services. They instantiate
a connection with the QBRSOAPServer class and all their methods deal
with invoking the corresponding web service operation.
Any outside class (see 3 below) that uses these intermediate classes
need not know about how they are actually working with web services, but
can think they are dealing with a regular class and go about using the
intermediate classes' methods in the usual way.
3. The client application classes that make use of these web service
operations by going through the methods of (2) are in


Suthanya Doung-In wrote:
> Dear Anupama,
> I am sorry that disappear for a while because I am study about
> Java web services. I am newbie for this.
> I create Writing web services in general - using Java and Apache
> Axis from
> http://trac.greenstone.org/browser/other-projects/trunk/gs3-webservices-democlient/docs/HowToFiles/7BasicsOfWritingWebServices.html?format=raw.
> It is successful.;-).
> Now try to create a client to invoke service. I do following the URL
> that you have ever recommended (How to write a simple client for
> Greenstone 3 web services) from :
> http://trac.greenstone.org/browser/other-projects/trunk/gs3-webservices-democlient/docs/HowToFiles/6WritingAWebServiceClient.html?format=raw.
> I used Netbean editor and then I compile this code but it got errors
> !!. I try to do following all the steps that instruct. I add required
> jar files and add some jar files to execution classpath. I think I do
> the right way. However i got errors;-(. Could you help me please ?. and
> if I got GreenstoneConnection.class after i comply this file what the
> next step I should going on?
> I sent the file that I capture the screens about What the steps I
> do and capture some errors. Please find the attached file.
> Many thanks in advance.
> Best Wishes,
> Suthanya Doung-in