The Client
----------

This portion of the project guides you through the task of creating a client to contact the web service
you set up in the previous step.  There are some important aspects to understand before building your
client.  First, we are using SOAP to send the data from the web service, so your client must understand
how to interpret this message.  Second, we are using Remote Procedure Calls (RPC's) to query the web 
service for the data, so you must understand how to invoke a RPC.  

The first part, understanding SOAP messaging is trivial, as Java takes care of all the overhead (translating
objects into SOAP messages on the service side, and then converting them back to objects on the client side). 
There are a couple aspects that could lead the first time developer into some difficult bugs and we will
address those here.  First, we must understand what objects SOAP already understands.  For a list of these types,
see here.  Because we have defined a new type
(our Stock class), we must tell SOAP how to understand it. The following lines of code tell the SOAP Registry how
to serialize our object:

		SOAPMappingRegistry registry = new SOAPMappingRegistry( );
		BeanSerializer serializer = new BeanSerializer( );
		registry.mapTypes(Constants.NS_URI_SOAP_ENC, 
				new QName("urn:soap-stock-demo", "stock"),
				Stock.class, serializer, serializer);  

It is important to note that the QName object must be the same as the one defined in the Deployment Descriptor
on the service side.  For more information on the Deployment Descriptor, see here. 
For an example for our tutorial, see here.  At this point, it's important to
understand that we didn't have to anything special to make our object serializable with SOAP.  This is because
JavaBeans is smart.  We wrote our Stock class to conform to the JavaBeans standard, and the BeanSerializer
intuitively knows how to serialize our new class. While writing serializer/deserializer classes is not the most
difficult thing in the world, it can get messy and things can get screwed up pretty quick.  By conforming our class
to the JavaBeans standard, we saved ourselves a lot of time.

Next, we need to understand how to invoke the RPC.  Essentially, we have a method (procedure) sitting in this
web service we just created and we need the client to call that method.  Again, Java makes this really simple.
The following lines of code will invoke the remote procedure in the service and return the SOAP response:

	//build call object
	Call call = new Call( );
	call.setSOAPMappingRegistry(registry);
	call.setTargetObjectURI("urn:quote-server");
	call.setMethodName("GetQuote");
	call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);

	//add paramters for call
	Vector parameters = new Vector();
	parameters.addElement(new Parameter("ticker", String.class, ticker, null));
	call.setParams(parameters);

	//make the call
	Response response;
	response = call.invoke(url,"");

For compiling instructions please see the Deployment section. 

We first just create a call object.  We map the registry object that we created above, so that the client 
understands the SOAP response.  We then set the method name, which is the name of the method in the service.
We add the parameter, which is going to be the ticker symbol in this case.  We then use the invoke method, 
which invokes the RPC and returns the SOAP response.

>From here, it is up to you to finishing writing the client code.  This is a relatively simple task and is
up to you how difficult you want to make it.  Basically, at a minimum, you must read a ticker symbol in from
STDIN and call the GetQuote method from the web service that you created.  You must convert that SOAP response
into a Stock object and call it's accessor methods to retreive the data for the stock.  You must then print 
this data out however you see fit.

A pretty good tutorial on all this stuff can be found here.
This link is pretty helpful in debugging SOAP applications.