background image

Examining MyUddiPing

<< MyUddiPing.java | SOAPConnectionFactory Class >>
<< MyUddiPing.java | SOAPConnectionFactory Class >>
154
SOAP
WITH
A
TTACHMENTS
API
FOR
J
AVA
The file
build.xml
is the
asant
build file for this example.
The file
build.properties
defines one property.
The file
uddi.properties
contains the URL of the destination (a UDDI test reg-
istry). To install this registry, follow the instructions in Preliminaries: Getting
Access to a Registry (page 175).
If the Application Server where you install the
registry is running on a remote system, open
uddi.properties
in a text editor
and replace
localhost
with the name of the remote system.
The
prepare
target creates a directory named
build
. To invoke the
prepare
tar-
get, you type the following at the command line:
asant prepare
The target named
build
compiles the source file
MyUddiPing.java
and puts the
resulting
.class
file in the
build
directory. So to do these tasks, you type the
following at the command line:
asant build
Examining MyUddiPing
We will go through the file
MyUddiPing.java
a few lines at a time, concentrat-
ing on the last section. This is the part of the application that accesses only the
content you want from the XML message returned by the UDDI registry.
The first lines of code import the interfaces used in the application.
import javax.xml.soap.SOAPConnectionFactory;
import javax.xml.soap.SOAPConnection;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPMessage;
import javax.xml.soap.SOAPHeader;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPBodyElement;
import javax.xml.soap.SOAPElement;
import javax.xml.namespace.QName;
import java.net.URL;
import java.util.Properties;
import java.util.Enumeration;
import java.util.Iterator;
import java.io.FileInputStream;