MetaBoss
User Guides
Synopsis
Beginner's Guide
Configuration Guide
Design Studio Guide
Programming Model Guide
Testing Framework Guide
'How To ...' Guides
References
Synopsis
Design Model Reference
Design Model UML Profile
Test Schema Reference
MetaBoss design library
Run-time libraries API
Dev-time libraries API
HatMaker Example
Synopsis
Enterprise Model Description
Enterprise Model Reference
SystemTest Example
WebServices Example
Miscellaneous
About MetaBoss
Quality Assurance
Compatibility Notes
Acknowledgments
Glossary
Change Log
Version 1.4.0001
Built on 15 Dec 2005 22:31:47

HatMaker WebServices Example Description.

Web Services Overview

In simple terms the Web Services technology could be described as ability to discover and invoke enterprise services remotely using "XML over HTTP" protocol. Rapid worldwide acceptance of Web Services is mostly due to the simplicity of protocol and interoperability between many different platforms.

From MetaBoss's point of view, Web Services is just another distribution technology used by clients to access Enterprise Services. MetaBoss enables creation of WebServices based on all or any modelled enterprise service. It does that by providing a special WebServices adapter code generator.

The MetaBoss Web Services generation capabilities are used to generate Web Services for the HatMaker example. In this example we show how to generate, deploy and use Web Services generated from the enterprise model. The source for the HatMaker Web Services example is located in ${metaboss_home}/examples/HatMaker/WebServices directory. Note that due to the huge size of the resulting binaries this portion of HatMaker example is not prebuilt. We will discuss building of the example latter in this document. Please note that MetaBoss's Web Services Server is built with and is dependent on a number of components from Sun's Java Web Services Developers Pack (JWSDP). The required components are redistributed with MetaBoss under ${metaboss_home}/thirdpartylib/jswdp-x.x (x.x. is the version of JWSDP. At the time of writing MetaBoss includes components from JWSDP-1.4). Please also note that test server deployment has been done using Apache Tomcat 5.0 included in JWSDP 1.4 (Tomcat is not redistributed by MetaBoss).

Hat Maker Web Services Scenario

Our HatMaker have got a very important client - HatBuyer. This client wants to communicate with HatMaker electronically and Web Services is a preferred technology.

Primarily HatBuyer wants to be able to order new hats and monitor progress of existing orders. In real enterprise we would most probably define a separate "Client SelfService" system (or Services inside other systems) and expose this system via Web Services. In order to keep it simple and because our example is not a real fully-fledged system, this example exposes a few already defined services as a Web Services.

To interconnect via Web Services the people at HatMaker and HatBuyer must do the following:

  • People at HatMaker must build Web Service definitions and servlets for all services to be exposed.
  • People at HatMaker must deploy these Web Services somewhere on internet, so the Web Services themselves and their definition files can be accessed from outside (or at the very least can be accessed by HatBuyer).
  • People at HatMaker must tell to the people at HatBuyer of the Internet URL where Web Services could be reached. Technically having URL is enough to discover and invoke the Web Service, so people at HatBuyer should not require anything else, apart from may be some documentation on use of the services.
  • People at HatBuyer build and deploy Web Service client applications using their favorite Web Service tools (absolutely no dependency on MetaBoss here). All necessary information about HatMaker services is obtained from the URL supplied by HatMaker.
Separate sections below discuss all these steps in more detail.

Building WebServices Server

Directory ${metaboss_home}/examples/HatMaker/WebServices/Server contains the Ant build file used to build the HTTP Servlet Application which is the front end to HatMaker Web Services. This directory also contains a number of batch files used to invoke ant build. The end goal of this build is to produce the Web Archive file (war file) deployable into a Servlet container such as Apache Tomcat. The full build of the WebServices Server Application module is done in one step using the MetaBossBuilder task. The MetaBossBuilder is an expert Ant task which is able to build the required components from the model without lots of additional information. Unlike most of the basic Ant tasks, which are procedural in nature, the MetaBossBuilder task is declarative. One is only required to specify the source Model Elements and the type of the desired target module. We call this approach "Model Driven Buld". In the example the MetaBossBuilder is asked to build three configuration of the WebServices Server Application:

  • Inprocess - this configuration executes services internally (i.e. does not delegate service execution anywhere). The MetaBossBuilder prepares the war file "with the lot". The resulting web archive file is placed in the ${metaboss_home}/examples/HatMaker/WebServices/Server/Release/Inprocess directory.
  • JBossClient - this configuration delegates the service execution to an implementation running inside JBoss container. The MetaBossBuilder prepares the war file with a thin WebService-to-JBosss proxy. The resulting web archive file is placed in the ${metaboss_home}/examples/HatMaker/WebServices/Server/Release/JBossClient directory.
  • Simulator - this configuration simulates service responses based on the XML data files. The MetaBossBuilder prepares the war file with a special simulator implementation (the simulator facility is a part of the MetaBoss Testing Framework). The resulting web archive file is placed in the ${metaboss_home}/examples/HatMaker/WebServices/Server/Release/Simulator directory.

Please note that in a real life project you will most probably standartise on the particular deployment strategy and will only be building one kind of WebServices Server Application. This means that the example build file is three times more complex and the sample build takes three times longer than it would take in real life.

Deploying the WebServices Server

Deployment of Web Services consists of setting up Tomcat with the right set of jar files and properties and deploying the war file with the Web Service servlet. Please note that we have tested and documented these deployment instructions using the Tomcat 5.0 servlet container supplied with JWSDP 1.4. When testing the JBossClient installation - the 3.0.4 version of JBoss was used.

The Tomcat setup depends on the chosen server configuration:

Deployment of the war files is done via Tomcat's Web Application manager. Please refer to Tomcat and JWSDP documentation for more details on how to use this feature. The actual war files to be deployed are located in the Inprocess, JBossClient or Simulator subdirectories located under the ${metaboss_home}/examples/HatMaker/WebServices/Server/Release directory.

Building the WebServices Java Client

Directory ${metaboss_home}/examples/HatMaker/WebServices/JavaClient contains the Ant build file used to build the Sample Web Service Java client - a simple command line java application calling a number of Web Services. This directory also contains a number of batch files used to invoke an ant build. The end goal of this build is to produce all classes necessary to run the client application. This build consists of the following major steps:

  1. Generate Web Services code for client stubs using the wscompile tool (part of JWSDP). The wscompile tool uses the WSDL file published by the WebServices server. This step is performed in the build target section named "webservice-client-generate".
  2. Compile all handcoded and generated pieces of code. The handcoded source file can be found at ${metaboss_home}/examples/HatMaker/WebServices/JavaClient/src/com/hatbuyer/services/SampleService.java. It contains a simple main() routine and example which invokes a couple of Web Services.
Some important points to note:
  • This build is not MetaBoss specific and does not use any tools out of the MetaBoss suite. All it is using is the wscompile tool which is part of JWSDP.
  • The Web Service Server has to be deployed and running for this build to succeed. This is because the wscompile tool uses the "live" Web Service to fetch the WSDL definition.
  • You also may have to alter the URL of the Web Service (port and host parts only!!) if you have deployed your Web Service somewhere other than at localhost:8080. The URLs are stated in the files with suffix '_wscompileconfig.xml'.

Building the WebServices .NET / C# Client

Directory ${metaboss_home}/examples/HatMaker/WebServices/DotNetClient contains the Ant build file used to build the Sample Web Service .NET / C# client - a simple command line C# executable calling a number of Web Services. This directory also contains a number of batch files used to invoke an ant build. The end goal of this build is to produce a runnable Windows executable. Please note that this part of the example depends on the Microsoft .NET Framework SDK being installed (We have used version 1.1). The DOS environment variables (PATH, LIB, INCLUDE etc...) must incorporate the appropriate SDK locations at the time the Ant script is run (otherwise the build will end up with an error). Microsoft .NET Framework SDK documentation provides more details on the installation and environment setting. This build consists of the following major steps:

  1. Generate Web Services code for client stubs using Wsdl tool (part of SDK). The Wsdl tool uses the WSDL file published by the WebServices server. This step is performedis in the build target section named "webservice-client-generate".
  2. Compile all handcoded and generated pieces of code. The handcoded source file can be found at ${metaboss_home}/examples/HatMaker/WebServices/DotNetClient/src/HatBuyer/Tests/HatMakerTest.cs. It contains a simple Main() routine. As an example this routine invokes a couple of Web Services.
Some important points to note:
  • This build is not MetaBoss specific and does not use any tools out of the MetaBoss suite. All it is using is the Wsdl tool which is part of the Microsoft .NET Framework SDK.
  • The Web Service Server has to be deployed and running for this build to succeed. This is because the Wsdl tool uses the "live" Web Service to fetch the WSDL definition.
  • You also may have to alter the URL of the Web Service (port and host parts only!!) if you have deployed your Web Service somewhere other than at localhost:8080. The Web server URL is set in the build.properties file and is used in the "webservice-client-generate" target of the build file.

Running the WebServices Clients

The Java and .NET/C# client applications can be run via the runtestclient.bat batch file located respectively in the JavaClient or DotNetClient subdirectores in the ${metaboss_home}/examples/HatMaker/WebServices folder. The Web Service Server has to be deployed and running for this run to succeed. If everything works as expected both client programs' output should look similar to the ones below:

The output from the Java client.
Sample Output From Web Service Java Client

The output from the .NET/C# client.
Sample Output From Web Service .NET / C# Client