Running the Client Examples


The simple client programs provided with this tutorial can be run from the command line. You can modify them to suit your needs. They allow you to specify the Java WSDP Registry Server for queries and updates. (To install the Registry Server files, follow the instructions in Preliminaries: Getting Access to a Registry (page 697).

The examples, in the <INSTALL>/javaeetutorial5/examples/jaxr/simple/src/ directory, are as follows:

  • JAXRQuery.java shows how to search a registry for organizations.

  • JAXRQueryByNAICSClassification.java shows how to search a registry using a common classification scheme.

  • JAXRQueryByWSDLClassification.java shows how to search a registry for web services that describe themselves by means of a WSDL document.

  • JAXRPublish.java shows how to publish an organization to a registry.

  • JAXRDelete.java shows how to remove an organization from a registry.

  • JAXRSaveClassificationScheme.java shows how to publish a classification scheme (specifically, a postal address scheme) to a registry.

  • JAXRPublishPostal.java shows how to publish an organization with a postal address for its primary contact.

  • JAXRQueryPostal.java shows how to retrieve postal address data from an organization.

  • JAXRDeleteScheme.java shows how to delete a classification scheme from a registry.

  • JAXRPublishConcept.java shows how to publish a concept for a WSDL document.

  • JAXRPublishHelloOrg.java shows how to publish an organization with a service binding that refers to a WSDL document.

  • JAXRDeleteConcept.java shows how to delete a concept.

  • JAXRGetMyObjects.java lists all the objects that you own in a registry.

The <INSTALL>/javaeetutorial5/examples/jaxr/simple/ directory also contains the following:

  • A build.xml file for the examples

  • A JAXRExamples.properties file, in the src subdirectory, that supplies string values used by the sample programs

  • A file called postalconcepts.xml that serves as the taxonomy file for the postal address examples

Before You Compile the Examples

Before you compile the examples, edit the file <INSTALL>/javaeetutorial5/examples/jaxr/simple/src/JAXRExamples.properties as follows.

1.

If the Application Server where you installed the Registry Server files is running on a system other than your own or if it is using a nondefault HTTP port, change the following lines:

query.url=http://localhost:8080/RegistryServer/ publish.url=http://localhost:8080/RegistryServer/ ... link.uri=http://localhost:8080/hello-jaxws/hello?WSDL ... wsdlorg.svcbnd.uri=http://localhost:8080/hello-jaxws/hello


Specify the fully qualified host name instead of localhost, or change 8080 to the correct value for your system.

2.

(Optional) Edit the following lines, which contain empty strings for the proxy hosts, to specify your own proxy settings. The proxy host is the system on your network through which you access the Internet; you usually specify it in your Internet browser settings.

## HTTP and HTTPS proxy host and port http.proxyHost= http.proxyPort=8080 https.proxyHost= https.proxyPort=8080


The proxy ports have the value 8080, which is the usual one; change this string if your proxy uses a different port.

Your entries usually follow this pattern:

http.proxyHost=proxyhost.mydomain http.proxyPort=8080 https.proxyHost=proxyhost.mydomain https.proxyPort=8080


You need to specify a proxy only if you want to specify an external link or service binding that is outside your firewall.

3.

Feel free to change any of the organization data in the remainder of the file. This data is used by the publishing and postal address examples.

You can edit the src/JAXRExamples.properties file at any time. The Ant targets that run the client examples will use the latest version of the file.

Note

Before you compile any of the examples, follow the preliminary setup instructions in Building the Examples (page xxxv).


Compiling the Examples

You can compile and run the examples using either the NetBeans 5.5 IDE or Ant.

To compile the programs using NetBeans 5.5, follow these steps:

1.

In NetBeans 5.5, choose Open Project from the File menu.

2.

In the Open Project dialog, navigate to <INSTALL>/javaeetutorial5/examples/jaxr/.

3.

Select the simple folder.

4.

Select the Open as Main Project checkbox.

5.

Click Open Project Folder.

A Reference Problems dialog appears. Click Close.

6.

Right-click the simple project and choose Resolve Reference Problems.

7.

In the Resolve Reference Problems dialog, select the first of the missing JAR files and click Resolve.

The missing files are appserv-ws.jar, javaee.jar, appserv-rt.jar, and commons-logging.jar.

8.

Navigate to the <JAVAEE_HOME>/lib/ directory.

9.

Select the missing JAR file (appserv-ws.jar, for example) and click Open.

In the Resolve Reference Problems dialog, all the files have green check marks to the left of their names.

10.

Click Close.

11.

Right-click the simple project and choose Build Project.

To compile the programs using Ant, follow these steps:

1.

In a terminal window, go to the following directory:

<INSTALL>/javaeetutorial5/examples/jaxr/simple/


2.

Type the following command:

ant


This command uses the default target, which performs the compilation. The Ant targets create subdirectories called build and dist.

Running the Examples

You must start the Application Server in order to run the examples against the Registry Server. For details, see Starting and Stopping the Application Server (page 27).

Getting a List of Your Registry Objects

To get a list of the objects you own in the registryorganizations, classification schemes, and conceptsrun the JAXRGetMyObjects program.

To run the program using NetBeans 5.5, follow these steps:

1.

Right-click the simple project and choose Properties.

2.

Select Run from the Categories tree.

3.

Click Browse next to the Main Class field.

4.

In the Browse Main Classes dialog, select JAXRGetMyObjects.

5.

Click Select Main Class.

6.

Click OK.

7.

Right-click the project and choose Run Project.

To run the program using Ant, use the run-get-objects target:

   ant run-get-objects


It is a good idea to run this program first to make sure the Registry Server is running properly.

Note

The first time you access the Registry Server, you are likely to see a runtime error. If you run the program a second time, the program should run correctly.


Because you are logged in as the default user, testuser, you will see a list of all the objects in the registry when you run this program. Most of these objects are classification schemes.

Running the JAXRPublish Example

To run the JAXRPublish program using NetBeans 5.5, follow these steps:

1.

Right-click the simple project and choose Properties.

2.

Select Run from the Categories tree.

3.

Click Browse next to the Main Class field.

4.

In the Browse Main Classes dialog, select JAXRPublish.

5.

Click Select Main Class.

6.

Click OK.

7.

Right-click the project and choose Run Project.

To run the program using Ant, use the run-publish target with no command-line arguments:

   ant run-publish


The program output displays the string value of the key of the new organization.

After you run the JAXRPublish program but before you run JAXRDelete, you can run JAXRQuery to look up the organization you published.

Note

When you run any program that publishes an object to the registry, a runtime warning appears in the server log (a com.sun.xnode.XNodeException). It is safe to ignore this warning.


Running the JAXRQuery Example

To run the JAXRQuery example, specify a string argument on the command line to search the registry for organizations whose names contain that string. Searching is not case-sensitive.

To run the program using NetBeans 5.5, follow these steps:

1.

Right-click the simple project and choose Properties.

2.

Select Run from the Categories tree.

3.

Click Browse next to the Main Class field.

4.

In the Browse Main Classes dialog, select JAXRQuery.

5.

Click Select Main Class.

6.

In the Arguments field, type the query string value (for example, coffee).

7.

Click OK.

8.

Right-click the project and choose Run Project.

To run the program using Ant, use the run-query target. Specify a query-string argument on the command line:

   ant -Dquery-string=coffee run-query


Running the JAXRQueryByNAICSClassification Example

After you run the JAXRPublish program, you can also run the JAXRQueryByNAICSClassification example, which looks for organizations that use the All Other Specialty Food Stores classification, the same one used for the organization created by JAXRPublish.

To run the program using NetBeans 5.5, follow these steps:

1.

Right-click the simple project and choose Properties.

2.

Select Run from the Categories tree.

3.

Click Browse next to the Main Class field.

4.

In the Browse Main Classes dialog, select JAXRQueryByNAICSClassification.

5.

Click Select Main Class.

You do not have to remove the argument string left over from the previous program. Since this program takes no arguments, the string will be ignored.

6.

Click OK.

7.

Right-click the project and choose Run Project.

8.

In the output window, find the ID string that follows Org key id: and select it.

9.

Right-click the selected text and choose Copy.

To run the program using Ant, use the run-query-naics target:

   ant run-query-naics


Running the JAXRDelete Example

To run the JAXRDelete program, specify the key string for the object you want to delete as input to the program. For example, you can use the key string displayed by the JAXRQueryByNAICSClassification program.

To run the program using NetBeans 5.5, follow these steps:

1.

Right-click the simple project and choose Properties.

2.

Select Run from the Categories tree.

3.

Click Browse next to the Main Class field.

4.

In the Browse Main Classes dialog, select JAXRDelete.

5.

Click Select Main Class.

6.

In the Arguments field, paste the string you copied when you ran the program in the previous section.

7.

Click OK.

8.

Right-click the project and choose Run Project.

To run the program using Ant, use the run-delete target. Specify a key-string argument on the command line:

   ant -Dkey-string=keyString run-delete


Publishing a Classification Scheme

To publish organizations with postal addresses, you must first publish a classification scheme for the postal address.

To run the JAXRSaveClassificationScheme program using NetBeans 5.5, follow these steps:

1.

Right-click the simple project and choose Properties.

2.

Select Run from the Categories tree.

3.

Click Browse next to the Main Class field.

4.

In the Browse Main Classes dialog, select JAXRSaveClassificationScheme.

5.

Click Select Main Class.

6.

Click OK.

7.

Right-click the project and choose Run Project.

8.

In the output window, find the UUID string that follows the string The postalScheme key is and select it.

9.

Right-click the selected text and choose Copy.

To run the program using Ant, use the run-save-scheme target:

   ant run-save-scheme


You will use the UUID string returned by this program in the next section.

Running the Postal Address Examples

Before you run the postal address examples, perform these steps:

1.

In the simple directory, open the file postalconcepts.xml in an editor.

2.

Wherever you see the string uuid-from-save, replace it with the UUID string returned by the JAXRSaveClassificationScheme program (including the uuid: prefix). Make sure there are no leading or trailing spaces in the string.

3.

Save and close the file.

For a given registry, you only need to publish the classification scheme and edit postalconcepts.xml once. After you perform those steps, you can run the JAXRPublishPostal and JAXRQueryPostal programs multiple times.

To run the JAXRPublishPostal program using NetBeans 5.5, follow these steps:

1.

Right-click the simple project and choose Properties.

2.

Select Run from the Categories tree.

3.

Click Browse next to the Main Class field.

4.

In the Browse Main Classes dialog, select JAXRPublishPostal.

5.

Click Select Main Class.

6.

In the Arguments field, paste the UUID string returned by the run-save-scheme target. The UUID string would look something like this:

uuid:938d9ccd-a74a-4c7e-864a-e6e2c6822519


7.

Click OK.

8.

Right-click the project and choose Run Project.

To run the JAXRQueryPostal program using NetBeans 5.5, follow these steps:

1.

Right-click the simple project and choose Properties.

2.

Select Run from the Categories tree.

3.

Click Browse next to the Main Class field.

4.

In the Browse Main Classes dialog, select JAXRQueryPostal.

5.

Click Select Main Class.

6.

In the Arguments field, type a query string, then the UUID string returned by the run-save-scheme target. The order is important. For example:

coffee uuidstring


7.

Click OK.

8.

Right-click the project and choose Run Project.

To run the JAXRPublishPostal program using Ant, specify the string you entered in the postalconcepts.xml file, including the uuid: prefix, as input to the run-publish-postal target:

   ant -Duuid-string=uuidstring run-publish-postal


The program output displays the string value of the key of the new organization.

To run the JAXRQueryPostal program using Ant, use the run-query-postal target. This target specifies the postalconcepts.xml file in a <sysproperty> tag.

As input to the run-query-postal target, specify both a query-string argument and a uuid-string argument on the command line to search the registry for the organization published by the run-publish-postal target:

   ant -Dquery-string=coffee -Duuid-string=uuidstring    run-query-postal


The postal address for the primary contact will appear correctly with the JAXR PostalAddress methods. Any postal addresses found that use other postal address schemes will appear as Slot lines.

If you want to delete the organization you published, follow the instructions in Running the JAXRDelete Example (page 727).

Deleting a Classification Scheme

To delete the classification scheme you published after you have finished using it, run the JAXRDeleteScheme program.

To run the program using NetBeans 5.5, follow these steps:

1.

Right-click the simple project and choose Properties.

2.

Select Run from the Categories tree.

3.

Click Browse next to the Main Class field.

4.

In the Browse Main Classes dialog, select JAXRDeleteScheme.

5.

Click Select Main Class.

6.

In the Arguments field, paste the UUID string for the postal address scheme.

7.

Click OK.

8.

Right-click the project and choose Run Project.

To run the program using Ant, use the run-delete-scheme target, specifying the UUID string:

   ant -Duuid-string=uuidstring run-delete-scheme


Publishing a Concept for a WSDL Document

The JAXRPublishConcept program publishes the location of the WSDL document for the JAX-WS Hello service described in Creating a Simple Web Service and Client with JAX-WS (page 508). Normally, you deploy the service before you publish the location of the WSDL document. However, this program runs correctly whether or not the service is deployed.

To run the JAXRPublishConcept program using NetBeans 5.5, follow these steps:

1.

Right-click the simple project and choose Properties.

2.

Select Run from the Categories tree.

3.

Click Browse next to the Main Class field.

4.

In the Browse Main Classes dialog, select JAXRPublishConcept.

5.

Click Select Main Class.

6.

Click OK.

7.

Right-click the project and choose Run Project.

8.

In the output window, find the UUID string that follows the string Concept key is and select it.

9.

Right-click the selected text and choose Copy.

To run the program using Ant, use the run-publish-concept target:

   ant run-publish-concept


The program output displays the UUID string of the new specification concept, which is named HelloConcept. You will use this string in the next section.

After you run the JAXRPublishConcept program, you can run JAXRPublishHelloOrg to publish an organization that uses this concept.

Publishing an Organization with a WSDL Document in Its Service Binding

To run the JAXRPublishHelloOrg example, specify the string returned from JAXRPublishConcept (including the uuid: prefix) as input to the program.

To run the program using NetBeans 5.5, follow these steps:

1.

Right-click the simple project and choose Properties.

2.

Select Run from the Categories tree.

3.

Click Browse next to the Main Class field.

4.

In the Browse Main Classes dialog, select JAXRPublishHelloOrg.

5.

Click Select Main Class.

6.

In the Arguments field, paste the UUID string for the concept. The uuidstring would look something like this:

uuid:10945f5c-f2e1-0945-2f07-5897ebcfaa35


7.

Click OK.

8.

Right-click the project and choose Run Project.

To run the program using Ant, use the run-publish-hello-org target:

   ant -Duuid-string=uuidstring run-publish-hello-org


The program output displays the string value of the key of the new organization, which is named Hello Organization.

After you publish the organization, run the JAXRQueryByWSDLClassification example to search for it. To delete it, run JAXRDelete.

Running the JAXRQueryByWSDLClassification Example

To run the JAXRQueryByWSDLClassification example, specify a string argument to search the registry for specification concepts whose names contain that string. Searching is not case-sensitive.

To run the program using NetBeans 5.5, follow these steps:

1.

Right-click the simple project and choose Properties.

2.

Select Run from the Categories tree.

3.

Click Browse next to the Main Class field.

4.

In the Browse Main Classes dialog, select JAXRQueryByWSDLClassification.

5.

Click Select Main Class.

6.

In the Arguments field, type helloconcept.

7.

Click OK.

8.

Right-click the project and choose Run Project.

To run the program using Ant, use the run-query-wsdl target:

   ant -Dquery-string=helloconcept run-query-wsdl


This example finds the concept and organization you published.

Deleting a Concept

To run the JAXRDeleteConcept program, specify the UUID string displayed by the JAXRPublishConcept program as input to the program. Do not delete the concept until after you have deleted any organizations that refer to it.

To run the program using NetBeans 5.5, follow these steps:

1.

Right-click the simple project and choose Properties.

2.

Select Run from the Categories tree.

3.

Click Browse next to the Main Class field.

4.

In the Browse Main Classes dialog, select JAXRDeleteConcept.

5.

Click Select Main Class.

6.

In the Arguments field, paste the UUID string for the concept.

7.

Click OK.

8.

Right-click the project and choose Run Project.

To run the program using Ant, use the run-delete-concept target:

   ant -Duuid-string=uuidString run-delete-concept


Other Targets

To remove the build and dist directories and the class files using NetBeans 5.5, right-click the simple project and choose Clean Project.

To perform this task using Ant, type the following command:

   ant clean


To obtain an Ant syntax reminder for all the targets, use the command

   ant -projecthelp




The JavaT EE 5 Tutorial
The JavaT EE 5 Tutorial
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 309

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net