Java
  Home arrow Java arrow Page 8 - Using RPC-Style Web Services with J2EE
Dev Shed Forums 
Administration  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Download TestComplete 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
JAVA

Using RPC-Style Web Services with J2EE
By: Sams Publishing
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 11
    2004-12-08

    Table of Contents:
  • Using RPC-Style Web Services with J2EE
  • Web Service Overview
  • Web Service Technologies and Protocols
  • Web Services for J2EE
  • RPC-Oriented Web Services
  • Creating a Simple Service
  • The WSDL File
  • Creating the Web Service WAR
  • The Web Services Deployment Descriptor
  • Building More Robust Web Services
  • Exposing EJBs Through Web Service Protocols
  • Web Service Compiler Configuration File
  • Configuring the EJB Component
  • Other Considerations for Web Services
  • Summary

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    Iron Speed
     
    ADVERTISEMENT

    Dell PowerEdge Servers

    Using RPC-Style Web Services with J2EE - Creating the Web Service WAR
    (Page 8 of 15 )

    You will package up the Web Service in a WAR file, so choose File, New, Web Component to create a new one. Click Next to skip the introduction screen and move onto the WAR file creation screen. You will be creating a New Stand-Alone WAR Module so ensure that this option is selected. Next, under WAR Naming, browse to a location in which you wish to save your WAR file and provide "wsgreeting" as the File Name.

    Now you can populate your WAR with the files you saw earlier. Under the Contents section, click the Edit button to display the Edit Contents of wsgreeting screen. Browse to find the class files (Greeting.class and GreetingImplementation.class), the WSDL file (GreetingService.wsdl – created in folder build/generated), and the mapping file (mapping.xml – created in folder build/generated). Add each of these files to the contents as shown in Figure 20.6 and click OK.

    bond

    Figure 20.6
    Populating the Web Service WAR with class and configuration files.

    Your WAR file settings should look similar to those in Figure 20.7.

    bond

    Figure 20.7
    The settings for the Web Service WAR file.

    Click Next to move on to the Choose Component Type screen and select Web Services Endpoint. Click Next to move onto the Choose Service screen. Under the Service Definition, the WSDL File drop-down list should offer you the GreetingService.wsdl file and the Mapping File drop-down list should offer you the mapping.xml file. Select these two files so that your screen looks like that in Figure 20.8. You will see that the service name has been picked up from the WSDL file.

    bond

    Figure 20.8
    Selecting the WSDL and mapping files.

    Now click Next to move onto the Component General Properties window. Select wsexamples.GreetingImplementation as your Service Endpoint Implementation (this will be offered from the drop-down list). Again, the fields will be populated based on the information in the file.

    Click Next to move on to the Web Service Endpoint screen. Select wsexamples.Greeting as your Service Endpoint Interface. In the WSDL Port section, set the Namespace to be urn:J2EE21Examples and ensure that the Local Part becomes GreetingPort as shown in Figure 20.9.

    bond

    Figure 20.9
    Configuring the Web Service Endpoint.

    That completes the initial configuration, so click Next followed by Finish. You should be presented with a deploytool screen that looks like Figure 20.10.

    bond

    Figure 20.10
    Web Service WAR in deploytool.

    Configuring the WAR and Component

    There are three final bits of Sun-specific configuration that are needed to complete the Web Service WAR. First, select the General tab of the wsgreeting WAR file (as shown in Figure 20.10). Set the Context Root field to /wsgreeting.

    Now select the GreetingImplementation component in the left-hand pane. Select the Aliases tab and Add an alias of /GreetingService as shown in Figure 20.11.

    Finally, select the Endpoint tab and change the Endpoint Address at the bottom of the tab to be GreetingService. You should now save your WAR file and you are ready to deploy your service.

    During this process, deploytool has generated several new files for you:

    • The web.xml file—This contains the servlet definition for your
      Web Service. One part of this defines a servlet and indicates that wsexamples.GreetingImplementation is the servlet class. Obviously, the GreetingImplementation class you saw earlier is not a servlet, but this is indicative of more Web Service scaffolding. As the Web component is marked as a Web Service, the container to which it is deployed will hook it up to a SOAP router servlet during deployment. The other part of the file is the alias you added mapping /GreetingService to the GreetingImplementation servlet:
      <servlet>
      <display-name>GreetingImplementation</display-name>
      <servlet-name>GreetingImplementation</servlet-name>
      <servlet-class>wsexamples.GreetingImplementation
      </servlet-class> </servlet> <servlet-mapping> <servlet-name>GreetingImplementation</servlet-name> <url-pattern>/GreetingService</url-pattern> </servlet-mapping>
    • The sun-web.xml file—This contains the sun-specific configuration performed toward the end of the configuration. This includes the setting of the context root and the mapping of the Web Service endpoint information (the names of the service and port) to the servlet used to implement the service:
      <sun-web-app>
      <context-root>/wsgreeting</context-root>
      <servlet>
      <servlet-name>GreetingImplementation</servlet-name>
      <webservice-endpoint>
      <port-component-name>Greeting</port-component-name>
      <endpoint-address-uri>GreetingService
      </endpoint-address-uri> </webservice-endpoint> </servlet> </sun-web-app>
    • The webservices.xml file— This file is described in the JSR109 document as the "Web Services Deployment Descriptor" and is described in the next section.

    bond

    Figure 20.11
    Adding an alias for the Web Service.

    This chapteris fromTeach Yourself J2EE in 21 Days, second edition, byMartin Bond et. al.(Sams, 2004, ISBN: 0-672-32558-6). Check it out at your favorite bookstore today. Buy this book now.

    More Java Articles
    More By Sams Publishing


       · I am trying to find out how to sign up for the mailing list (Java) but I can't seem...
     

       

    JAVA ARTICLES

    - The Spring Framework: Understanding IoC
    - Introducing the Spring Framework
    - Java Classes
    - Completing the Syntactic Comparison of Java ...
    - Syntactic Comparison of Java and C/C++
    - Java Statements
    - Conditionals, Expressions and Other Java Ope...
    - Java Operators
    - Primitive Data Types and Basic Language Rule...
    - Java and Object-Oriented Programming
    - Java Beginning Programming
    - Gaming Development Setup
    - Using RPC-Style Web Services with J2EE
    - Integrating XML with J2EE
    - Taming Tiger: Concurrent Collections

    Iron Speed
     
    Accelerating Trading Partner Performance
     
    Competing on Analytics
     
    Cost Effective Scaling with Virtualization and Coyote Point Systems
     
    Five Checkpoints to Implementing IP Telephony
     
    Hosted Email Security: Staying Ahead of New Threats
     




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway