spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / programming / java / webservices / chap3 / 2 current pageTo page 2To page 3To page 4To page 5
[next]

Professional Java Web Services

Developer News
Mandrake Linux Founder Back, Virtually
Amazon: We're a Technology Company
Sun Expands MySQL With Closed Source

Deploying and Running a "Hello World" Service

[The following is a continuation of our series of excerpts from chapter 3 of the Wrox Press title, Professional Java Web Services.]

Now that we have Apache SOAP installed and configured let's deploy and run a simple service called "Hello World". There are two ways a service can be deployed: via the Apache SOAP command line tool or via the web-based administration tool. We are going to discuss both methods within this section. We will also discuss how to use an Apache SOAP client to run the service. We will not dive into the details of implementing the service or the client, but will defer this discussion until the Developing SOAP Services and Developing SOAP Clients sections, respectively.

HelloWorld.java

The Java class that will implement the "Hello World" service is located in HelloWorld.java, which is listed below:

package com.wrox.helloworld.service;

public class HelloWorld {

  String getMessage() {
    return "Hello World!";
  }
}

Notice that this class only has one method, getMessage(). We will expose this method through the "Hello World" service. This means that SOAP clients will be able to invoke this method.

In order to utilize the HelloWorld class it must be accessible from the Apache SOAP run-time environment, which is hosted within Tomcat. This means that the HelloWorld class has to be accessible from Tomcat. This can be achieved by doing the following:

  1. Create a JAR file called helloworld.jar with the contents containing the com.wrox.helloworld.service.HelloWorld class.
  2. Copy the helloworld.jar file to <TOMCAT_HOME>\lib\

Deploying Via the Command Line

In order for the getMessage() method to be exposed a deployment descriptor for the service has to be created and registered with the Apache SOAP run-time environment. In this section we discuss the details of deployment descriptors and how to register the service using the Apache SOAP command line tool.

Deployment Descriptors

A deployment descriptor is an XML document that provides the details of the service to the Apache SOAP run-time environment. The format of a deployment descriptor depends on the type of code artifact. The term code artifact is usually used to refer to a software component that contains logic that can be invoked via methods or functions. A code artifact can be written in any language. Apache SOAP ships with support for the following code artifacts:

Support for standard Java classes includes support for JavaBeans. Support for EJBs includes stateless session beans, stateful session beans, and entity beans. The BSF framework can be used to allow SOAP services to be written in any BSF-supported scripting language such as Rhino. Rhino is an opensource implementation of JavaScript that supports the BSF framework. Rhino is written completely in Java and is maintained by mozilla.org. More information about BSF and Rhino can be located at http://oss.software.ibm.com/developerworks/projects/bsf/ and http://www.mozilla.org/rhino/.

Apache SOAP defines a different deployment descriptor for each one the aforementioned code artifacts. We will discuss the deployment descriptor for a standard Java class. This is best done using an example, so we will discuss the deployment descriptor for the "Hello World" service, which is implemented as a standard Java class. The deployment descriptor for the "Hello World" service is located in a file called HelloWorldDD.xml. It's listed below:

<?xml version="1.0"?>
<isd:service xmlns:isd="http://xml.apache.org/xml-soap/deployment"
             id="urn:HelloWorldService">
  <isd:provider type="java"
                scope="Application"
                methods="getMessage">
  <isd:java class="com.wrox.helloworld.service.HelloWorld" static="false"/>
  </isd:provider>
  <isd:faultListener>org.apache.soap.server.DOMFaultListener</isd:faultListener>
</isd:service>

In order to understand this, we will go through each element to see how it is used.


home / programming / java / webservices / chap3 / 2 current pageTo page 2To page 3To page 4To page 5
[next]

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Whitepapers and eBooks

Intel Whitepaper: Comparing Two- and Four-Socket Platforms for Server Virtualization
IBM Solutions Brief: Go Green With IBM System xTM And Intel
HP eBook: Simplifying SQL Server Management
IBM Contest: Are You the Next Superstar? Join the "Search for the XML Superstar" Contest to Find Out
Microsoft PDF: Top 10 Reasons to Move to Server Virtualization with Hyper-V
Microsoft PDF: Six Reasons Why Microsoft's Hyper-V Will Overtake Vmware
Microsoft Step-by-Step Guide: Hyper-V and Failover Clustering
Intel PDF: Quad-Core Impacts More Than the Data Center
Intel PDF: Virtualization Delivers Data Center Efficiency
Go Parallel Article: PDC 2008 in Review
Microsoft PDF: Top 11 Reasons to Upgrade to Windows Server 2008
Avaya Article: Communication-Enabled Mashups: Empowering Both Business Owners and IT
Intel Whitepaper: Building a Real-World Model to Assess Virtualization Platforms
  PDF: Intel Centrino Duo Processor Technology with Intel Core2 Duo Processor
Microsoft Article: Build and Run Virtual Machines with Hyper-V Server 2008
Go Parallel Article: Q&A with a TBB Junkie
IBM Whitepaper: Innovative Collaboration to Advance Your Business
Internet.com eBook: Real Life Rails
IBM eBook: The Pros and Cons of Outsourcing
Internet.com eBook: Best Practices for Developing a Web Site
IBM CXO Whitepaper: The 2008 Global CEO Study "The Enterprise of the Future"
Avaya Article: Call Control XML in Action - A CCXML Auto Attendant
IBM CXO Whitepaper: Unlocking the DNA of the Adaptable Workforce--The Global Human Capital Study 2008
Adobe Acrobat Connect Pro: Web Conferencing and eLearning Whitepapers
HP eBook: Guide to Storage Networking
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
webref The latest from WebReference.com Browse >
Popular JavaScript Framework Libraries: An Overview - Part 3 · Accessing Your MySQL Database from the Web with PHP · Working with the DOM Stylesheets Collection
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Crucial Triples Up With New Three-Channel DDR3 Kits · Meet the Finalists: Excellence in Technology Awards · Tealeaf Offers Insight to Mobile Customer Behavior

Created: May 23, 2002
Revised: May 23, 2002

URL: http://webreference.com/programming/java/webservices/chap3/2/