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>/javaeetutorial5/examples/jaxr/simple/src/directory, are as follows:
JAXRQuery.javashows how to search a registry for organizations.JAXRQueryByNAICSClassification.javashows how to search a registry using a common classification scheme.JAXRQueryByWSDLClassification.javashows how to search a registry for web services that describe themselves by means of a WSDL document.JAXRPublish.javashows how to publish an organization to a registry.JAXRDelete.javashows how to remove an organization from a registry.JAXRSaveClassificationScheme.javashows how to publish a classification scheme (specifically, a postal address scheme) to a registry.JAXRPublishPostal.javashows how to publish an organization with a postal address for its primary contact.JAXRQueryPostal.javashows how to retrieve postal address data from an organization.JAXRDeleteScheme.javashows how to delete a classification scheme from a registry.JAXRPublishConcept.javashows how to publish a concept for a WSDL document.JAXRPublishHelloOrg.javashows how to publish an organization with a service binding that refers to a WSDL document.JAXRDeleteConcept.javashows how to delete a concept.JAXRGetMyObjects.javalists all the objects that you own in a registry.The
<INSTALL>/javaeetutorial5/examples/jaxr/simple/directory also contains the following:
- A
build.xmlfile for the examples- A
JAXRExamples.propertiesfile, in thesrcsubdirectory, that supplies string values used by the sample programs- A file called
postalconcepts.xmlthat serves as the taxonomy file for the postal address examplesYou 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.javaandJAXRPublishHelloOrg.java.Before You Compile the Examples
Before you compile the examples, edit the file
<INSTALL>/javaeetutorial5/examples/jaxr/simple/src/JAXRExamples.propertiesas follows.
- If the Application Server where you installed the Registry Server 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/helloSpecify the fully qualified host name instead of
localhost, or change8080to the correct value for your system.- (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=8080The 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=8080You need to specify a proxy only if you want to specify an external link or service binding that is outside your firewall.
- 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.propertiesfile 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 xxxi).
Compiling the Examples
To compile the programs, go to the
<INSTALL>/javaeetutorial5/examples/jaxr/simple/directory. Abuild.xml file allows you to use the following command to compile all the examples:This command uses the default target, which performs the compilation. The Ant targets create subdirectories called
buildanddist.Running the Examples
You must startApplication Server in order to run the examples against the Registry Server. For details, see Starting and Stopping the Application Server (page 28).
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
JAXRGetMyObjectsprogram by using therun-get-objectstarget:It is a good idea to run this program first to make sure the Registry Server is running properly. 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
JAXRPublishprogram, use therun-publishtarget with no command-line arguments:The program output displays the string value of the key of the new organization.
After you run the
JAXRPublishprogram but before you runJAXRDelete, you can runJAXRQueryto 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
JAXRQueryexample, use the Ant targetrun-query. Specify aquery-stringargument 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):Running the JAXRQueryByNAICSClassification Example
After you run the
JAXRPublishprogram, you can also run theJAXRQueryByNAICSClassificationexample, which looks for organizations that use the All Other Specialty Food Stores classification, the same one used for the organization created byJAXRPublish. To do so, use the Ant targetrun-query-naics:Running the JAXRDelete Example
To run the
JAXRDeleteprogram, specify the key string displayed by theJAXRPublishprogram as input to therun-deletetarget:Publishing a Classification Scheme
To publish organizations with postal addresses, you must first publish a classification scheme for the postal address.
To run the
JAXRSaveClassificationSchemeprogram, use the targetrun-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:
For a given registry, you only need to publish the classification scheme and edit
postalconcepts.xmlonce. After you perform those steps, you can run theJAXRPublishPostalandJAXRQueryPostalprograms multiple times.
- Run the
JAXRPublishPostalprogram. Specify the string you entered in thepostalconcepts.xmlfile, including theuuid:prefix, as input to therun-publish-postaltarget:
ant -Duuid-string=uuidstringrun-publish-postalThe
uuidstringwould look something like this:
uuid:938d9ccd-a74a-4c7e-864a-e6e2c6822519The program output displays the string value of the key of the new organization.
- Run the
JAXRQueryPostalprogram. Therun-query-postaltarget specifies thepostalconcepts.xmlfile in a<sysproperty>tag.As input to the
run-query-postaltarget, specify both aquery-stringargument and auuid-stringargument on the command line to search the registry for the organization published by therun-publish-postaltarget:
ant -Dquery-string=coffee
-Duuid-string=uuidstringrun-query-postalThe postal address for the primary contact will appear correctly with the JAXR
PostalAddressmethods. Any postal addresses found that use other postal address schemes will appear asSlotlines.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
JAXRDeleteSchemeprogram using therun-delete-schemetarget:Publishing a Concept for a WSDL Document
The
JAXRPublishConceptprogram publishes the location of the WSDL document for the JAX-WSHelloservice described in Creating a Simple Web Service and Client with JAX-WS (page 496). 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
JAXRPublishConceptprogram, use the Ant targetrun-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
JAXRPublishConceptprogram, you can runJAXRPublishHelloOrgto publish an organization that uses this concept.Publishing an Organization with a WSDL Document in Its Service Binding
To run the
JAXRPublishHelloOrgexample, use the Ant targetrun-publish-hello-org. Specify the string returned fromJAXRPublishConcept(including theuuid:prefix) as input to this target:The
uuidstringwould look something like this: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
JAXRQueryByWSDLClassificationexample to search for it. To delete it, runJAXRDelete.Running the JAXRQueryByWSDLClassification Example
To run the
JAXRQueryByWSDLClassificationexample, use the Ant targetrun-query-wsdl. Specify aquery-stringargument 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):This example finds the concept and organization you published.
Deleting a Concept
To run the
JAXRDeleteConceptprogram, specify the UUID string displayed by theJAXRPublishConceptprogram as input to therun-delete-concepttarget:Do not delete the concept until after you have deleted any organizations that refer to it.
Other Targets
To remove the
buildanddistdirectories and the class files, use the commandTo obtain a syntax reminder for the targets, use the command