Java CAPS Sample Documentation


<font color="red">Working with the Oracle Java CAPS Repository Samples for Oracle JAX-WS</font>

Working with the Oracle Java CAPS Repository Samples for Oracle JAX-WS


The following procedures provide general instructions for working with the Oracle JAX-WS sample projects and performing tasks using Oracle JDeveloper. For more detailed instructions on using JDeveloper, see the Oracle Fusion Middleware Developer's Guide for Oracle SOA Suite.

Note that all procedures in this document are based on Java CAPS 6.3 and Oracle JDeveloper 11.1.1.4. Some steps might vary if you are using an earlier version of Oracle JDeveloper.

Overview

The purpose of the sample projects provided for Oracle JAX-WS and Java CAPS (Repository) is to illustrate how to call Java CAPS Repository-based web services using Oracle JAX-WS.

When you extract the ZIP file containing the samples, the Java CAPS project is located in proj_JAXWS_Rep\projBP.zip. The sample includes one Java CAPS Business Process Manager (BPM) project named projBP and one Java CAPS Environment, ENV_WS_BP. The ZIP file containing the samples also includes sample WSDL files, but you will want to use the WSDL files you generate when you deploy your own projects.

This tutorial covers the following procedures:


Installing the Java CAPS Sample Projects

One sample project using a BPM business process is provided on the Java CAPS Sample Code page. The Java CAPS project ZIP file includes one project and one environment.

This procedure requires that the Java CAPS Repository be running.

  1. Download proj_JAXWS_Rep.zip.

    This file is also available from the Java CAPS sample code site under the Oracle JAX-WS and JAX-RPC tab.

  2. Extract the downloaded file into a temporary directory.

  3. Launch NetBeans, and verify that you are connected to the Repository.

  4. From the NetBeans toolbar, select Tools, point to CAPS Repository, and then select Import Project.

  5. On the Import Project dialog box, click Yes to proceed, or click No to save any changes to the Repository and repeat the previous step.

  6. On the Import Manager, click Browse and navigate to the temporary directory where you extracted proj_JAXWS_Rep.zip.

  7. Select projBP.zip and click Open.

    One project, projBP, appears in the selected projects list, and one Environment, ENV_WS_BP, appears in the list of environments to import.

  8. Make sure Destination Project is set to As Top-Level.

  9. Click Import.

  10. On the confirmation dialog box that appears, click OK.

    The Repository is refreshed, the project appears in the Projects window, and the environment appears in the Services window.


Calling a Java CAPS BPM Web Service from Oracle JAX-WS

This process creates an Oracle JAX-WS project that calls the web service generated by the Java CAPS project projBP, which is a Business Process Manager (BPM) project. It includes the following steps:


Configuring and Deploying the projBP Project

This procedure includes deploying the Java CAPS project to the GlassFish server. Before you begin, make sure the GlassFish server is running. You can start the server by right-clicking GlassFish v2.x under the Servers node in the NetBeans Services window.

  1. In the NetBeans Services window, expand CAPS Environments.

  2. Right-click ENV_WS_BP, point to Version Control, and then select Checkout. On the Version Control - Check Out window, click Check Out.

  3. Do the following to configure the server:

    1. Under ENV_WS_BP, right-click WS_Server and select Properties.

      The Properties window appears.

    2. In the navigation tree on the left, select Web Service External System Configuration.

    3. Verify the Port and Host Name and update if needed.

      This is the host name and port number for the web service being deployed on the GlassFish server.

    4. Verify the Servlet Context and update if needed. Click OK.

  4. Do the following to configure the application server:

    1. Under ENV_WS_BP, expand LogicalHost1.

    2. Right-click SunJavaSystemApplicationServer1, point to Version Control, and then select Check Out. Click Check Out on the window that appears.

    3. Right-click SunJavaSystemApplicationServer1, and select Properties.

      The Properties window appears.

    4. In the navigation tree on the left, select Sun Java System Application Server Configuration.

    5. Verify the application server URL, user name, and password, and update if needed. Click OK.

  5. Do the following to configure the projBP project:

    1. On the NetBeans Projects window, expand projBP and right-click server.

    2. Point to Version, and then select Checkout. On the Version Control - Check Out window, click Check Out.

    3. Right-click BpelProcess1, and then click Properties.

    4. Update the Target Namespace field, and then click OK.

    5. Save and close the business process.

    6. Open the CAPSWS WSDL document, switch to source code view, and then update the soap:address element at the bottom of the file.

    7. Save and close the file.

  6. Do the following to deploy the projBP project:

    1. On the NetBeans Projects window, right-click BP_server, point to New, and then select Deployment Profile.

    2. Enter a name for the profile, and for the Environment select ENV_WS_BP.

    3. Click OK.

    4. On the Deployment Profile Editor, click Automap.

      The connectivity components are automatically moved into the Environment containers.

    5. In the Deployment Profile Editor toolbar, click Build.

      During the build process, a dialog appears so you can export the JAR file containing the WSDL file. Navigate to where you want to store the file, enter a name for the file, and click Export.

    6. After the build is complete, click Deploy.

  7. Tip: You should use this exported WSDL file in the Oracle JAX-WS project rather than the WSDL file provided in the sample files. To use the file you exported, you need to extract it from the JAR file generated by the build process.


Creating a JAX-WS Project to Call the projBP Project

In this procedure, you will create a JAX-WS application in Oracle SOA Suite that calls the web service generated from a BPM project in Java CAPS.

  1. Launch Oracle JDeveloper.

  2. From the Application menu, select New.

    The Create Application wizard appears.

  3. On the Name Your Application page, enter JaxWsApp for the name, and specify the directory to store the project in (or accept the default).

  4. Under Application Template, select Generic Application.

  5. Click Next.

    The Name Your Project window page appears.

  6. Enter JaxWsProj for the name.

  7. Click Finish.

    The application Overview page appears in JDeveloper.


Adding and Configuring the Web Service Proxy

  1. In the left navigation panel, right-click JaxWsProj and then click New.

    The New Gallery wizard appears.

  2. Under Categories, go to Business Tier and select Web Services.

  3. Under Items, select Web Service Proxy.

  4. Click OK.

    The Create Web Service Proxy Wizard appears.

  5. Click Next, and select JAX-WS Style on the Select Client Style page.

    The Select Web Service Description page appears.

  6. Enter the URL for the WSDL document generated from the Java CAPS project above, or browse to and select the file on your file system.

  7. Select Copy WSDL Into Project, and then click Next.

    The Building Model dialog box appears. When the model is complete, the Specify Default Mapping Options page appears.

  8. For both the Package Name and Root Package for Generated Types, enter capsws and then click Next.

    The Port Endpoint page appears.

  9. Make sure the endpoint URL is correct, and then click Next.

    The Asynchronous Methods page appears.

  10. Accept the default values, and click Next.

    The Building Policies dialog box appears. When the policies are complete, the Policy page appears.

  11. Accept the default values, and click Next.

    The Defined Handlers page appears.

  12. In the Port drop-down list, select CAPSWSPort.

  13. Click Next and then click Finish.

    The web service files are generated and the CAPSWSPortClient.java appears in a JDeveloper editor.


Creating the Java Class to Invoke the Web Service Proxy

  1. In the left panel of JDeveloper, right-click JaxWsProj and select New.

    The New Gallery Wizard appears.

  2. Under Categories, select General.

  3. Under Items, select Java Class.

  4. Click OK.

    The Create Java Class Wizard appears.

  5. In the Name field, enter JaxWsService, and then click OK.

    The Java file framework is generated, and the JaxWsService.java file appears in a JDeveloper editor.

  6. Add two public methods named echo and invokeCAPS_WS, along with the necessary import statements and annotations. The final code should be similar to the following.

    		package jaxwsproj;
    		import javax.jws.WebMethod;
    		import javax.jws.WebService;
    		import javax.xml.ws.WebServiceRef;
    		import capsws.CAPSWSService;
    
    		@WebService
    		public class JaxWsService {
    
    		  @WebServiceRef
    		  private CAPSWSService capssvc;
    
    		    public JaxWsService() {
    		        super();
    		    }
    
    		    @WebMethod
    		    public String echo(String message){
    		      return " Echoed from Oracle JaxWsService: "+message;
    		  }
    		    @WebMethod
    		    public String invokeCAPS_WS(String message) {
    		      String ret = capssvc.getCAPSWSPort().capswsOperation(message);
    		      return " Got reply from CAPS Web Service: "+ret;
    		  }
    		}
    		
  7. Save the Java file.

  8. To the right of the Java file, select the yellow marker.

    The @WebService; line is highlighted and a bulb appears to the left of the line.

  9. Right-click the bulb, and select Configure web.xml.

  10. In the Projects list on the left, right-click JaxWsService.java (under Application Sources > jaxwsproj), and select Web Service Properties.

    The Java Web Service Editor appears.

  11. Keep all settings and click OK.

  12. Save all changes.


Deploying and Testing the Web Service Proxy Project

This process deploys the Project to the WebLogic server. Before you begin, make sure your WebLogic server is running and that your JDeveloper instance is connected to the server. Make sure that the projBP project is deployed and running in Java CAPS as described earlier.

  1. If prompted, enter the user name and password.

  2. Right-click the JaxWsProj Project and select Deploy > WebServices.

    A deployment wizard appears.

  3. Select Deploy to Application Server, and then click Next.

  4. Accept the default deployment configuration and click Next.

    The Select Server page appears.

  5. Select the application server to which to deploy the project, and then click Next.

    Note: If there are no application server connections defined, you can add a connection to your server by clicking the plus sign above the application server list.

    The SOA Servers page appears.

  6. Select the SOA Server to which to deploy, select the partition name, and then click next.

  7. Review the details on the Summary page, and then click Finish.

  8. If prompted, enter the user name and password.

  9. Once the project is deployed, you can test the project from Oracle Enterprise Manager. The URL for the WSDL to use for testing will be similar to http://localhost:7101/JaxWsApp-JaxWsProj-context-root/jaxWsServiceService. You can verify the SOAP address by right-clicking JaxWsService.java in JDeveloper, and then clicking Show WSDL for Web Service Annotations.

    For information about testing web services, see Testing WebLogic Web Services in Security and Administrator's Guide for Web Services.