background image

connection.call() Method

<< SOAPBodyElement Class | getChildElements() Method >>
<< SOAPBodyElement Class | getChildElements() Method >>
M
Y
U
DDI
P
ING
.
JAVA
157
Next, the message
message
is sent to the destination that
endpoint
represents,
which is the UDDI test registry. The
call
method will block until it gets a
SOAP-
Message
object back, at which point it returns the reply.
SOAPMessage reply = connection.call(message, endpoint);
In the next lines of code, the first line prints a line giving the URL of the sender
(the test registry), and the others display the returned message.
System.out.println("\n\nReceived reply from: " +
endpoint);
System.out.println("\n---- Reply Message ----\n");
reply.writeTo(System.out);
The returned message is the complete SOAP message, an XML document, as it
looks when it comes over the wire. It is a
businessList
that follows the format
specified
in
http://uddi.org/pubs/DataStructure-V2.03-Published-
20020719.htm#_Toc25130802
.
As interesting as it is to see the XML that is actually transmitted, the XML docu-
ment format does not make it easy to see the text that is the message's content.
To remedy this, the last part of
MyUddiPing.java
contains code that prints only
the text content of the response, making it much easier to see the information you
want.
Because the content is in the
SOAPBody
object, the first step is to access it, as
shown in the following line of code.
SOAPBody replyBody = reply.getSOAPBody();
Next, the code displays a message describing the content:
System.out.println("\n\nContent extracted from " +
"the reply message:\n");
To display the content of the message, the code uses the known format of the
reply message. First, it gets all the reply body's child elements named
busi-
nessList
:
Iterator businessListIterator =
replyBody.getChildElements(new QName(
"urn:uddi-org:api_v2",
"businessList"));