background image

SOAPConnectionFactory Class

<< Examining MyUddiPing | SOAPBodyElement Class >>
<< Examining MyUddiPing | SOAPBodyElement Class >>
M
Y
U
DDI
P
ING
.
JAVA
155
The next few lines begin the definition of the class
MyUddiPing
, which starts
with the definition of its
main
method. The first thing it does is to check to see
whether two arguments were supplied. If they were not, it prints a usage message
and exits. The usage message mentions only one argument; the other is supplied
by the
build.xml
target.
public class MyUddiPing {
public static void main(String[] args) {
try {
if (args.length != 2) {
System.err.println("Usage: asant run " +
"-Dbusiness-name=<name>");
System.exit(1);
}
The following lines create a
java.util.Properties
object that contains the
system properties and the properties from the file
uddi.properties
, which is in
the
myuddiping
directory.
Properties myprops = new Properties();
myprops.load(new FileInputStream(args[0]));
Properties props = System.getProperties();
Enumeration propNames = myprops.propertyNames();
while (propNames.hasMoreElements()) {
String s = (String) propNames.nextElement();
props.setProperty(s, myprops.getProperty(s));
}
The next four lines create a
SOAPMessage
object. First, the code gets an instance
of
SOAPConnectionFactory
and uses it to create a connection. Then it gets an
instance of a SOAP 1.1
MessageFactory
, using the
MessageFactory
instance to
create a message.
SOAPConnectionFactory soapConnectionFactory =
SOAPConnectionFactory.newInstance();
SOAPConnection connection =
soapConnectionFactory.createConnection();
MessageFactory messageFactory =
MessageFactory.newInstance();
SOAPMessage message = messageFactory.createMessage();