Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

Use the Eclipse SOA Tools Platform plug-in to build and deploy a Web service

The Eclipse plug-in for easy Web services development

Tyler Anderson, Freelance Writer, Backstop Media
Tyler Anderson received his bachelor's degree in computer science in 2004 and his master's degree in electrical and computer engineering in 2005 from Brigham Young University. He worked with Stexar Corp. as a design engineer from May 2005 to August 2006. He was discovered by Backstop Media LLC in early 2005, and has written and coded numerous articles and tutorials for IBM developerWorks.

Summary:  Work on the Eclipse SOA Tools Platform (STP) plug-in is well under way, and we should expect lots of new features to aid Service-Oriented Architecture (SOA) deployment in the coming months. The Eclipse STP became the ninth top-level project for the Eclipse organization in 2005, and since then, development has come a long way. With the Eclipse STP plug-in, you can go from a Java™ interface, annotate it with Web service-related properties, create a Web Services Description Language (WSDL) for the Web service, generate and code Java stubs you can then compile into a WAR file, and deploy on your favorite Web server. This tutorial shows you how to accomplish all this using the Eclipse STP plug-in.

Date:  27 Mar 2007
Level:  Intermediate PDF:  A4 and Letter (780 KB | 34 pages)Get Adobe® Reader®

Activity:  26566 views
Comments:  

Deployment and testing

Seems like we're ready to deploy and test the Web service. In this section, we package our Web service for deployment, deploy it, and test it using Representational State Transfer (REST) and the client you've built.

Creating a deployment package of your Web service

Before you can run the stand-alone server and test the Web service, you need to package your code in a WAR file for deployment:

  • Select the WSDL file in the Navigator view
  • Click SOA > Generate Deploy Package

That creates a deployable WAR file at WebContent/ScientificCalculator.war in your project.

Now you're good to move on and run the stand-alone Web server.


Running the stand-alone Web server

The development framework comes with a stand-alone Web server, which allows you to perform testing of your Web service within the Eclipse framework.

Note that the STP plug-in has created a couple preconfigured run configurations. To run the server:

  1. Double-click the Java interface in the Navigator view
  2. Click Run > Run
  3. Select Java Application > ScientificCalculatorServer_server_com.ibm.dw.scicalc, as shown in Figure 7
  4. Click Run

Figure 7. Running the server
Running the server

The server should then run and let you know it's ready.


Figure 8. Server ready
Server ready

Now point your browser to http://localhost:8080/ScientificCalculator/services/ScientificCalculatorService?wsdl and you should see the WSDL. Next, we test the Web service in a browser using REST.


Testing using REST

With a browser pointed to the WSDL of the Web service, you can now test operations on it. Point your browser to http://localhost:8080/ScientificCalculator/services/ScientificCalculatorService/square?square0=4.5.

Notice that we're calling the square operation with 4.5 as the parameter. You'll get a file of type soap+xml, that will show 20.25 as the result, as shown in the SOAP message that gets returned below.


Listing 15. SOAP message response
                    
<soap:Envelope
     xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
  <soap:Body>
    <ns2:return xmlns:ns2="http://scicalc.dw.ibm.com/"
                xmlns="http://www.w3.org/2005/08/addressing/wsdl">
      20.25
    </ns2:return>
  </soap:Body>
</soap:Envelope>

You can see the answer is 20.25. Feel free to test out the other operations using REST. Next, we do a more regressive test using your client.


Testing by running the client code

Now that you know your service is up and functional with a REST test, you can perform a more rigorous and all-encompassing test using your client. To run the client:

  1. Double click the Java interface in the Navigator view
  2. Click Run > Run
  3. Select Java Application > ScientificCalculatorClient_client_com.ibm.dw.scicalc
  4. Select the Arguments tab
  5. Replace the "Program arguments" pane with http://localhost:8080/ScientificCalculator/services/ScientificCalculatorService?wsdl, as shown in Figure 9
  6. Click Run

Figure 9. Configuring the client
Configuring the client

After clicking Run, the client will run and execute each operation in the console, as shown below.


Figure 10. Results of executing the client
Results of executing the client

You can see the server output of the client's execution by switching to its console, as shown below.


Figure 11. Server output
Server output

There you are! You have a completely functional Web service. Next, we do a final test by deploying the Web service on Apache Tomcat.


Deploying and testing on Apache Tomcat

Before you begin setting up Tomcat inside of Eclipse, you first need to copy some jars over to Tomcat's shared/lib directory by doing the following: Copy all jars except cxf-integration-jbi-*.jar (note the asterisk being a wildcard), or cxf-integration-jbi-2.0-incubator-RC-SNAPSHOT.jar for this tutorial, from CXF-Runtime-install-directory/lib to Tomcat-install-directory/shared/lib.

OK -- you're ready to move on and deploy the package on Tomcat using the Eclipse DTP. You'll begin by creating a new connector (the first four steps are also for if you want to optional start the Tomcat server within Eclipse):

  1. Click File > New > Other
  2. Open the Server folder and select Server
  3. Select, under the Apache folder, Tomcat v5.5 Server
  4. Click Finish
  5. Now click File > New > Other
  6. Open the Connection Profiles folder and select Connection Profile
  7. Select Tomcat Connection Profile
  8. Click Next
  9. Enter a name, Tomcat 5.5, and click Next
  10. Browse for the directory you installed Tomcat to (C:\apps\tomcat-5.5.20 for this tutorial)
  11. Click Finish

To deploy on Tomcat, start the Tomcat server by running startup.bat (Windows®) or startup.sh (Linux®). Once Tomcat is running, deploy your Web service by:

  1. Selecting the WAR file in the Navigator view
  2. Right-clicking it and selecting Deploy, as shown below


    Figure 12. Server output
    Server output

  3. Click the connection profile you made, Tomcat 5.5, and click OK
  4. If you've deployed before, you'll get a warning message, as shown in Figure 13. Click OK


    Figure 13. Possible ignorable warning message
    Possible ignorable warning message

Now run the client as before, and you should get exactly the same output shown in Figure 10. Tomcat's standard output should also display what's shown in Figure 11.

We have built and tested a Web service successfully using the Eclipse STP plug-in.

9 of 13 | Previous | Next

Comments



Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Open source, SOA and Web services
ArticleID=203494
TutorialTitle=Use the Eclipse SOA Tools Platform plug-in to build and deploy a Web service
publish-date=03272007
author1-email=tyleranderson5@yahoo.com
author1-email-cc=

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere).

My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Try IBM PureSystems. No charge.