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, follow the instructions in Preliminaries: Getting Access to a Registry.

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

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

You do not have to have the Application Server running in order to run most of these client examples. You do need to have it running in order to run JAXRPublishConcept.java and JAXRPublishHelloOrg.java.

Before You Compile the Examples

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

  1. If on a system other than your own or if it is using a nondefault HTTP port, change the following lines:
  2. 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.

  3. (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.
  4. ## 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.

  5. 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. Try to make the organization names unusual so that queries will return relatively few results.

You can edit the JAXRExamples.properties file at any time. The 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.


Compiling the Examples

To compile the programs, go to the <INSTALL>//examples/jaxr/ directory. A build.xml file allows you to use the following command to compile all the examples:

ant 

This command uses the default target, build, which performs the compilation. The tool creates a subdirectory called build.

Running the Examples

You must startApplication Server in order to run the examples against the Registry Server.

Running the JAXRPublish Example

To run the JAXRPublish program, 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.

Running the JAXRQuery Example

To run the JAXRQuery example, use the target run-query. Specify a query-string argument on the command line to search the registry for organizations whose names contain that string. For example, the following command line searches for organizations whose names contain the string "coffee" (searching is not case-sensitive):

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 do so, use the target run-query-naics:

ant run-query-naics 

Running the JAXRDelete Example

To run the JAXRDelete program, specify the key string displayed by the JAXRPublish program as input to the run-delete target:

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, use the target run-save-scheme:

ant run-save-scheme 

The program returns a UUID string, which you will use in the next section.

Running the Postal Address Examples

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

  1. Open the file src/postalconcepts.xml in an editor.
  2. Wherever you see the string uuid-from-save, replace it with the UUID string returned by the run-save-scheme target (including the uuid: prefix).

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.

  1. Run the JAXRPublishPostal program. Specify the string you entered in the postalconcepts.xml file, including the uuid: prefix, as input to the run-publish-postal target:
  2. ant -Duuid-string=uuidstring run-publish-postal

    The uuidstring would look something like this:

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

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

  3. Run the JAXRQueryPostal program. The run-query-postal target specifies the postalconcepts.xml file in a <sysproperty> tag.
  4. 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.

Deleting a Classification Scheme

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

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

Publishing a Concept for a WSDL Document

To publish the location of the WSDL document for the JAX-WS Hello service, first deploy the service to the Application Server as described in Creating a Simple Web Service and Client with JAX-WS.

Then run the JAXRPublishConcept program using 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, use the target run-publish-hello-org. Specify the string returned from JAXRPublishConcept (including the uuid: prefix) as input to this target:

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

The uuidstring would look something like this:

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

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, use the target run-query-wsdl. Specify a query-string argument on the command line to search the registry for specification concepts whose names contain that string. For example, the following command line searches for concepts whose names contain the string "helloconcept" (searching is not case-sensitive):

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 run-delete-concept target:

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

Do not delete the concept until after you have deleted any organizations that refer to it.

Getting a List of Your Registry Objects

To get a list of the objects you own in the registry--organizations, classification schemes, and concepts--run the JAXRGetMyObjects program by using the run-get-objects target:

ant run-get-objects 

Other Targets

To remove the build directory and class files, use the command

ant clean 

To obtain a syntax reminder for the targets, use the command

ant -projecthelp 

Editing the Properties File

  1. Feel free to change any of the organization data in the file. In the tree component, expand the Resources node, then expand the Connectors node.
  2. Click Connector Connection Pools.

The build.xml file in the clientsession directory defines Ant targets that package the clientsession application. To package the application, use the following command:

asant pack-ear 

The pack-ear target depends on the pack-client and pack-ejb targets, which in turn depend on the build target.

The pack-client target creates a JAR file that contains the client class file, a manifest file, and the file.

The pack-ejb target packages the session bean. It creates a JAR file that contains the bean class files, a manifest file, and the file.

The pack-ear target packages the two JAR files along with an application.xml file. It creates a file named clientsession.ear in the clientsession directory.

The build.xml file in the clientsession directory defines an Ant target that deploys the clientsession.ear file and returns a client JAR file. Use the following command:

asant deploy-ear 

This command deploys the application and returns a JAR file named clientsessionClient.jar in the clientsession directory.

To run the client, use the following command:

appclient -client clientsessionClient.jar 

After you run the example, use the following command to undeploy the application:

asant undeploy-ear 

You can use the run-delete target in the simple directory to delete the organization that was published.