Skip Headers
Oracle® SOA Suite Tutorial
Release 3 (10.1.3.1.0)

Part Number B28937-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Master Index
Master Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
View PDF

6 Creating the RapidService Project

This chapter describes how to create the RapidService project. It contains these sections:

6.1 About the RapidService Project

The RapidService project represents a supplier that provides price quotes for customer orders. The other supplier which it competes with is SelectManufacturer. The supplier that provides the lower quote for a customer's order gets to fulfill the order.

In the case of the RapidService and CreditService projects, the descriptors are generated at design time. The RapidService project is developed in a "bottom-up" fashion: you start with Java classes and you develop a WSDL file from the Java classes. CreditService is the opposite: it is developed in a "top-down" fashion, where you start with a WSDL and using this WSDL file, you generate Java classes.

6.2 Create a New Project for RapidService

Start by creating a new project for RapidService in JDeveloper:

  1. Right-click the SOADEMO application, and select New Project.

  2. In the New Gallery, in the Categories section, expand General and select Projects. In the Items section, select Empty Project.

    Figure 6-1 New Gallery for RapidService Project

    Description of Figure 6-1 follows
    Description of "Figure 6-1 New Gallery for RapidService Project"

    Click OK.

  3. In the Create Project dialog, enter RapidService in the Project Name field.

    Figure 6-2 Create Project Dialog for RapidService Project

    Description of Figure 6-2 follows
    Description of "Figure 6-2 Create Project Dialog for RapidService Project"

    Click OK.

    In the Application Navigator, you should see an empty RapidService project located under the SOADEMO application.

  4. Select File > Save to save your work.

6.3 Add JSR-181 Library to the RapidService Project

Before you can compile and deploy the RapidService project, you need to add the JSR-181 library to it. RequestQuote.java, which you will create in Section 6.6, "Create RequestQuote.java", contains JSR-181 annotations.

  1. Right-click the RapidService project and select Project Properties. In the Project Properties dialog, select Libraries on the left side.

    Figure 6-3 Project Properties Dialog

    Description of Figure 6-3 follows
    Description of "Figure 6-3 Project Properties Dialog"

  2. Click Add Library.

  3. In the Add Library dialog, select JSR-181 Web Services, located under Extension.

    Figure 6-4 Add Library Dialog

    Description of Figure 6-4 follows
    Description of "Figure 6-4 Add Library Dialog"

  4. Click OK in the Add Library dialog. In the Project Properties dialog, you should see the JSR-181 library added to the list.

    Figure 6-5 Project Properties Dialog with JSR-181 Library Added

    Description of Figure 6-5 follows
    Description of "Figure 6-5 Project Properties Dialog with JSR-181 Library Added"

  5. Click OK in the Project Properties dialog.

  6. Select the RapidService project in the Application Navigator and select File > Save to save your work.

6.4 Create Item.java

  1. Right-click the RapidService project, and select New. In the New Gallery, in the Categories section, expand General and select Simple Files. In the Items section, select Java Class.

    Figure 6-6 New Gallery for Creating a Simple Java Class

    Description of Figure 6-6 follows
    Description of "Figure 6-6 New Gallery for Creating a Simple Java Class"

    Click OK. This displays the Create Java Class dialog.

  2. In the Create Java Class dialog, enter these values:

    • Name: enter Item.

    • Package: enter org.soademo.rapidservice.types.

    • Extends: enter java.lang.Object.

    • Public: select this option.

    • Generate Default Constructor: select this option.

    • Generate Main Method: do not select.

    Click OK. JDeveloper displays the Item.java file in the editor.

  3. Edit the file so that it contains the following lines:

    package org.soademo.rapidservice.types;
    
    public class Item {
        public Item() {
        }
        
        String itemId;
        long Quantity;
    
        public void setItemId(String itemId) {
            this.itemId = itemId;
        }
    
        public String getItemId() {
            return itemId;
        }
    
        public void setQuantity(long quantity) {
            this.Quantity = quantity;
        }
    
        public long getQuantity() {
            return Quantity;
        }
    }
    
    
  4. Select File > Save to save the file.

6.5 Create Quote.java

  1. Right-click the RapidService project, and select New. In the New Gallery, in the Categories section, expand General and select Simple Files. In the Items section, select Java Class.

    Figure 6-7 New Gallery Dialog for Creating a Simple Java Class

    Description of Figure 6-7 follows
    Description of "Figure 6-7 New Gallery Dialog for Creating a Simple Java Class"

    Click OK. This displays the Create Java Class dialog.

  2. In the Create Java Class dialog, enter these values:

    • Name: enter Quote.

    • Package: enter org.soademo.rapidservice.types.

    • Extends: enter java.lang.Object.

    • Public: select this option.

    • Generate Default Constructor: select this option.

    • Generate Main Method: do not select.

    Figure 6-8 Create Java Class Dialog for Quote.java

    Description of Figure 6-8 follows
    Description of "Figure 6-8 Create Java Class Dialog for Quote.java"

    Click OK. JDeveloper displays the Quote.java file in the editor.

  3. Edit the file so that it contains the following lines:

    package org.soademo.rapidservice.types;
    
    public class Quote implements java.io.Serializable {
        protected java.lang.String supplierName;
        protected java.lang.String supplierPrice;
        
        public Quote() {
        }
    
        public java.lang.String getSupplierName() {
            return supplierName;
        }
    
        public void setSupplierName(java.lang.String supplierName) {
            this.supplierName = supplierName;
        }
    
        public java.lang.String getSupplierPrice() {
            return supplierPrice;
        }
    
        public void setSupplierPrice(java.lang.String supplierPrice) {
            this.supplierPrice = supplierPrice;
        }
    }
    
    
  4. Select File > Save to save the file.

6.6 Create RequestQuote.java

  1. Right-click the RapidService project, and select New. In the New Gallery, in the Categories section, expand General and select Simple Files. In the Items section, select Java Class.

    Figure 6-9 New Gallery for Creating a Simple Java Class

    Description of Figure 6-9 follows
    Description of "Figure 6-9 New Gallery for Creating a Simple Java Class"

    Click OK. This displays the Create Java Class dialog.

  2. In the Create Java Class dialog, enter these values:

    • Name: enter RequestQuote.

    • Package: enter org.soademo.rapidservice. Note that this is different from the previous Java classes you created.

    • Extends: enter java.lang.Object.

    • Public: select this option.

    • Generate Default Constructor: select this option.

    • Generate Main Method: do not select.

    Figure 6-10 Create Java Class Dialog for RequestQuote.java

    Description of Figure 6-10 follows
    Description of "Figure 6-10 Create Java Class Dialog for RequestQuote.java"

    Click OK. JDeveloper displays the file in the editor.

  3. Edit the file so that it contains the following lines:

    package org.soademo.rapidservice;
    
    import javax.jws.WebMethod;
    import javax.jws.WebService;
    
    import org.soademo.rapidservice.types.Item;
    import org.soademo.rapidservice.types.Quote;
    
    @WebService(serviceName="RapidService",
                targetNamespace="http://www.globalcompany.com/ns/rapidservice")
    
    public class RequestQuote {
        public RequestQuote() {
        }
    
        @WebMethod(operationName="OrderQuote")
        public Quote processRequestQuote(String productName, String itenType, 
                                         String partnum, String quantity, 
                                         String price) {
            Quote priceQuote = new Quote();
            priceQuote.setSupplierName("RapidDistributors");
            priceQuote.setSupplierPrice("5000");
            return priceQuote;
        }
        
        @WebMethod(operationName="POItemsQuote")
        public Quote processQuote(Item[] items){
            Long totalPrice = new Long(0);
            for ( int i=0; i<items.length; i++)  {
                Item localItem = items[i];
                totalPrice += localItem.getQuantity()*110;
            }
            Quote priceQuote = new Quote();
            priceQuote.setSupplierName("RapidDistributors");
            priceQuote.setSupplierPrice(totalPrice.toString());
            return priceQuote;
        }
    }
    
    
  4. Select File > Save to save the file.

6.7 Check Files in the Application Navigator

In the Application Navigator, you should see the following files for the RapidService project:

Figure 6-11 Application Navigator Showing Files for RapidService

Description of Figure 6-11 follows
Description of "Figure 6-11 Application Navigator Showing Files for RapidService"

6.8 Compile the Files

Right-click the RapidService project and select Rebuild. Check the log window for any errors.

6.9 Publish the Project as a Web Service

  1. Right-click the RapidService project, and select New. In the New Gallery, in the Categories section, expand Business Tier and select Web Services. In the Items section, select Java Web Service.

    Figure 6-12 New Gallery for Generating Java Web Services

    Description of Figure 6-12 follows
    Description of "Figure 6-12 New Gallery for Generating Java Web Services"

    Click OK. This displays the Create J2EE Web Service Version dialog.

  2. In the Select J2EE Web Service Version dialog, select J2EE 1.4 (JAX-RPC) Web Service and click OK.

    Figure 6-13 Select J2EE Web Service Version Dialog

    Description of Figure 6-13 follows
    Description of "Figure 6-13 Select J2EE Web Service Version Dialog"

    This launches the Create Java J2EE 1.4 Web Service wizard. Click Next to start.

  3. In Step 1, Class:

    • Web Service Name: enter RapidService.

    • Component to Publish: select org.soademo.rapidservice.RequestQuote from the dropdown.

    • Autogenerate Service Endpoint Interface: select this option (should be automatically selected for you).

    • Service Endpoint Interface: select org.soademo.rapidservice.RequestQuotePortType (this should be entered for you automatically).

    • SOAP 1.1 Binding: select this option.

    • SOAP 1.2 Binding: do not select.

    • WSIF Binding: do not select.

    • Generate annotations into class: select this option.

    Figure 6-14 Create Java J2EE 1.4 Web Service Wizard: Step 1, Class

    Description of Figure 6-14 follows
    Description of "Figure 6-14 Create Java J2EE 1.4 Web Service Wizard: Step 1, Class"

    Click Next.

  4. In Step 2, Message Format:

    • SOAP Message Format: select Document/Wrapped.

    • Enable REST Access to SOAP Ports: do not select.

    • Generate Schema with Qualified Elements: select this option.

    • Use DIME Encoding: do not select.

    Figure 6-15 Create Java J2EE 1.4 Web Service Wizard: Step 2, Message Format

    Description of Figure 6-15 follows
    Description of "Figure 6-15 Create Java J2EE 1.4 Web Service Wizard: Step 2, Message Format"

    Click Next.

  5. In Step 3, Specify Custom Data Type Serializers, click Next.

    Figure 6-16 Create Java J2EE 1.4 Web Service Wizard: Step 3, Specify Custom Data Type Serializers

    Description of Figure 6-16 follows
    Description of "Figure 6-16 Create Java J2EE 1.4 Web Service Wizard: Step 3, Specify Custom Data Type Serializers"

  6. In Step 4, Mapping, click Next.

    Figure 6-17 Create Java J2EE 1.4 Web Service Wizard: Step 4, Mapping

    Description of Figure 6-17 follows
    Description of "Figure 6-17 Create Java J2EE 1.4 Web Service Wizard: Step 4, Mapping"

  7. In Step 5, Methods, select processQuote and processRequestQuote.

    Figure 6-18 Create Java J2EE 1.4 Web Service Wizard: Step 5, Methods

    Description of Figure 6-18 follows
    Description of "Figure 6-18 Create Java J2EE 1.4 Web Service Wizard: Step 5, Methods"

    Click Next.

  8. In Step 6, Handler Details, click Next.

    Figure 6-19 Create Java J2EE 1.4 Web Service Wizard: Step 6, Handler Details

    Description of Figure 6-19 follows
    Description of "Figure 6-19 Create Java J2EE 1.4 Web Service Wizard: Step 6, Handler Details"

  9. In Step 7, State, click Next.

    Figure 6-20 Create Java J2EE 1.4 Web Service Wizard: Step 7, State

    Description of Figure 6-20 follows
    Description of "Figure 6-20 Create Java J2EE 1.4 Web Service Wizard: Step 7, State"

  10. In Step 8, Additional Classes, click Next.

    Figure 6-21 Create Java J2EE 1.4 Web Service Wizard: Step 8, Additional Classes

    Description of Figure 6-21 follows
    Description of "Figure 6-21 Create Java J2EE 1.4 Web Service Wizard: Step 8, Additional Classes"

  11. In the Finish page, click Finish.

JDeveloper displays the RapidService.wsdl file in the editor. RapidService.wsdl is one of the files created by the wizard.

Continue with the next section to see the files JDeveloper created.

6.10 Verify the Hostname and Port in the Generated WSDL File

Verify that the hostname and port in the RapidService.wsdl file are correct.

  1. If RapidService.wsdl is not displayed in the editor, double-click it in the Application Navigator. The file is located under RapidService > Web Content > WEB-INF\wsdl.

  2. Under Services, expand RequestQuoteSoapHttpPort.

    Figure 6-22 RapidService.wsdl

    Description of Figure 6-22 follows
    Description of "Figure 6-22 RapidService.wsdl"

  3. Right-click soap:address and select Properties. This displays the soap:address Properties dialog.

  4. In the soap:address Properties dialog, verify that the hostname and port are correct. The hostname specifies the name of the machine running Oracle Application Server, and the port specifies the HTTP port at which Oracle HTTP Server or OC4J is listening.

    Figure 6-23 soap:address Properties Dialog for RapidService.wsdl

    Description of Figure 6-23 follows
    Description of "Figure 6-23 soap:address Properties Dialog for RapidService.wsdl"

  5. Save your changes, if you made any.

6.11 Check Files in the Application Navigator

After the wizard has completed, you should see the following files in the Application Navigator and Structure window.

  1. Select View > Structure to display the Structure window.

  2. In the Application Navigator, select SOADEMO > RapidService > Application Sources > org.soademo.rapidservice > RapidService.

    In the Structure window, you should see the following files:

    • RequestQuote.java

    • RequestQuotePortType.java

    • RapidService.wsdl

    • RapidService-java-wsdl-mapping.xml

    Figure 6-24 Structure Window Showing Files Created

    Description of Figure 6-24 follows
    Description of "Figure 6-24 Structure Window Showing Files Created"

  3. Expand the SOADEMO > RapidService > Web Content node in the Application Navigator to see the other files that JDeveloper created. See Figure 6-24.

6.12 Set the Context Root to RapidService

  1. Double-click the RapidService project to display the Project Properties dialog.

  2. On the left side, select J2EE Application.

  3. Set the value of J2EE Web Application Name and J2EE Web Context Root to RapidService.

    Figure 6-25 Project Properties Dialog for RapidService

    Description of Figure 6-25 follows
    Description of "Figure 6-25 Project Properties Dialog for RapidService"

  4. Click OK.

  5. Select File > Save to save your work.

6.13 Edit the Deployment Descriptor

  1. Double-click the deployment descriptor (Resources > WebServices.deploy) to display the WAR Deployment Profile Properties dialog.

  2. Select General on the left side.

  3. Set Enterprise Application Name to RapidService.

    Figure 6-26 WAR Deployment Profile Properties Dialog, General Section

    Description of Figure 6-26 follows
    Description of "Figure 6-26 WAR Deployment Profile Properties Dialog, General Section"

  4. Click OK.

  5. Select File > Save to save your work.

6.14 Deploy the RapidService Project

Right-click Resources > WebServices.deploy and select Deploy To > SoademoApplicationServer, where SoademoApplicationServer specifies the connection to your application server.

In the Configure Application dialog, click OK.

Figure 6-27 Configure Application Dialog

Description of Figure 6-27 follows
Description of "Figure 6-27 Configure Application Dialog"

6.15 View the WSDL for RapidService

You can access the WSDL for RapidService by entering the following URL in a browser:

http://hostname:port/RapidService/RequestQuoteSoapHttpPort?WSDL

For hostname, enter the name of the machine running Oracle Application Server.

For port, enter the HTTP at which Oracle HTTP Server or OC4J is listening. The default port is 8888.

In the Application Server Control, RapidService appears in two places: in the Web Services tab (Figure 6-28) and the Applications tab (Figure 6-29) of the OC4J:home page.

Figure 6-28 Web Services Tab of OC4J:home Page Showing the RapidService Web Service

Description of Figure 6-28 follows
Description of "Figure 6-28 Web Services Tab of OC4J:home Page Showing the RapidService Web Service"

Figure 6-29 Applications Tab of OC4J:home Page Showing the RapidService Application

Description of Figure 6-29 follows
Description of "Figure 6-29 Applications Tab of OC4J:home Page Showing the RapidService Application"