Using Cross Project References

Contributed by Michael Nazarov, maintained by Irina Filippova
December 2007

This tutorial describes how to create a project reference to an XML file in another project.

Expected duration: 30 minutes

Contents

  Content on this page applies to the NetBeans 6.0 IDE

top

Tutorial Requirements


Before you proceed, review the requirements in this section.

Prerequisites

This tutorial assumes that you have basic knowledge of the following technologies:

Software Needed for This Tutorial

Before you begin, you need to install the following software on your computer: NetBeans IDE 6.0 with SOA and the GlassFish application server.

top

Overview

This tutorial illustrates the basic steps to create a project that references an XML file that belongs to another project. Use the principals in this tutorial to streamline the reuse of XML files within a set of project.

In the tutorial you create two projects. The first project is one of the SOA Blue Print Sample projects provided with NetBeans 6.0. The second is a BPEL Module project. From the BPEL Module project, you reference an XML schema file from the Blue Print Sample project.

top

Create The Projects

To create the Blue Print Sample project:

  1. In the NetBeans IDE, select the Projects tab to display the Projects window.
  2. From the File menu, select New Project.
  3. In the Categories list of the New Project window, select Samples > SOA > BPEL BluePrints > BluePrint1 and click Next.

    SOA BluePrint Sample Projects
  4. Accept the default name and location (or specify an alternate location using the Browse button).
  5. Click Finish to create the project.
    The following projects appear in the Projects window:

    BluePrint1, the BPEL project
    BluePrint1Application, the composite application project

    BluePrint Sample Project

To create the BPEL module project:

  1. From the File menu, select New Project.
  2. In the Categories list of the New Project window, select > SOA > BPEL Module and click Next.

    Select BPEL Module Project
  3. Accept the default project name and location (or specify an alternate location using the Browse button).
  4. Click Finish to create the project.

    The following project appears in the Projects window:

    BpelModule1

    BPEL Module Project

top

Establish a Reference Between the Projects

This sections shows how to create a reference to the BpelModule1 project from the BluePrint1 project. Once the reference is created, resources in the Blue Print project can be accessed by the BPEL Module project.

To establish a reference between the projects:

  1. In the Projects window, right-click the BluePrint1 project and select Properties.
  2. In the Project Properties dialog, under Categories, select Project References.
  3. Select Add Project.
  4. In the Add Project dialog, select the BpelModule1 project and click Add Project.

    Add Project Reference
  5. Click OK.

top

Import an XML Schema File Using a Project Reference

In this section you add an XML schema file to the BPEL Module project. You then modify the XML schema file using the XML schema structures referenced from a file in the Blue Print Sample project.

To add an XML schema file to the BPEL Module project:

  1. In the Project Window, right click BpelModule1 node and select New > Other to open the New File wizard.
  2. With BpelModule1 as the selected project, make the following selections and then click Next:

    Categories: XML
    File Types: Loan Application Sample Schema

    Import Schema File
  3. Accept the default Name and Location, and click Finish.

    The NetBeans IDE adds the new file to the BpelModule1 project and opens the file in the Schema View of the XML Editor.

    Import Schema File


To import the Loan Application Schema File into the Blue Print Sample project:

  1. In the Project Window, expand the BluePrint1 > Process Files node and select purchaseOrder.xsd.
  2. Double-click purchaseOrder.xsd to open this file for editing.

    If the Schema View is not selected in the editor, select Schema.
  3. In the leftmost column of the editor, right-click Referenced Schemas and choose Add > Import.
  4. In the Add Import Dialog expand the following node:

    By File > BpelModule > Process Files
  5. Select newLoanApplication.xsd for importing and click OK.

    Import Schema File

top

Use the Imported Schema File

In this section you choose the CarType element in the imported file.

To select an element from an imported file:

  1. In the Schema View of the editor for purchaseOrder.xsd, right-click the Elements in the leftmost column and select Add Element.
  2. In the Add Element window, accept the default name for the element and select Use Exiting Type.
  3. Expand the following node:

    Referenced Schemas > import {http://xml.netbeans.org/examples/LoanApplication} > Complex Types
  4. Select the CarType type and click OK.

    Selecting Referenced XML Schema Type
  5. Click OK.
  6. From the File menu, select Save All to save your work.

top

Check the Usage of the Imported Schema File

In this section you check that the newLoanApplication.xsd file is imported into the BluePrint1 project.

To find the usage of an imported XML schema file:

  1. In the Project window, expand the following node:

    BpelModule1 > Process Files
  2. Right click newLoanApplication.xsd and select Find Usages.

    The Usages window for the XML schema file opens in Logical View.

    Find Usages of an XML Schema
  3. In the Usages window, note that the XML schema is used by the BluePrint1 project.

top

Deploy the Blue Print Sample Composite Application

In this section you deploy the Blue Print Sample composite application, which contains the cross project reference.

To deploy the Blue Print Sample composite application:

top

Send Us Your Feedback