University of Cincinnati logo and link  
Chat as a Web Service
 
  Editor's Note:  I originally intended to make a full scale Chat Web Service.  But, as I wrote this example, I quickly realized two things:
  • Runnig this web service will require modifications to environment variables, system files, and more.  While possible on a home computer, these capabilities are locked down at UC's labs, and for good reason.
  • Writing the web service is easy.  Deploying a web service requires extensive knowledge of a Web Server (Tomcat), war files, ANT, and more.  This goes beyond the scope and time available for this class.  But, we can still cover more than the course proposal by setting up our Chat program to be a web service.
  • Later, we'll write a client that uses an existing web service.


UC ingot Let's try to make a simple web service out of Chat. 

    • We'll want to make a copy of the original program.  I named my copy chatService.  I also took out the package, for simplicity.
    • Let's take out some complexity - comment out the logging in the Chat interface, thus making it a local method.
    • We know we'll need to make some changes to the client as well, but let's focus on the server now.
  • So I ran wscompile.bat, and ran into a whack of problems.  It appears that the file comes with weird line breaks that Windows does not like. 
    • So I reinstalled the whole thing, and still got the problems.
    • I commented out unneeded lines, still got the problems.
    • The only thing that appeared to work was copying the contents of the file, saving the old as a backup, then making a new file to overwrite the original, with the contents of the copied text from the first file.
    • I also noticed the reference to setenv.bat was incorrect, so I fixed it and I copied the file into the local directory.
  • Then I realized I was missing the configuration file, config.xml.  So I went to the documentation to see what that requires.
    • I played around with the config.xml file for a little bit.  The final version is displayed on the next page.  I eliminated the package statement since I took my classes out of the class path, but it didn't like that.  So I put it back in, but with blank quotes, and it didn't like that either.  So I gave up and put the classes back in a package.
    • I tried may iterations of the command to start the wscompile program.  The one provided on the command line didn't work.  So I tried a few combinations from the documentation.  The one that finally worked is:

    • C:\jwsdp-1.1\jaxrpc-1.0.3\bin\wscompile.bat -gen -classpath "C:\Projects\30IT398\chatService" config.xml
      • I must stress, I went through a lot of iterations of this before I got it to work. 
      • The -d generate tag gave me trouble, possibly because I did not have a generate subdirectory.  I added this subdirectory, tried again, and it worked. 
      • I also found out that you must specify the classpath in quotes on windows.  I shortened the classpath to "." and it worked as well.
      • I also ran gen:server.
 config.xml