Java Reference
In-Depth Information
soapel.addChildElement("isbn").addTextNode("9781430234135").setAttribute("xsi:type",
Attachmentsareinstancesofconcretesubclassesoftheabstract AttachmentPart
class. If you need to include an attachment with the SOAP message, call one of
SOAPMessage 's createAttachmentPart() methods to create and return an
AttachmentPart object.Afterconfiguringthisobject,call SOAPMessage 's void
addAttachmentPart(AttachmentPart attachmentPart) method to add
the given attachmentPart -referenced object to this SOAPMessage object.
To send the SOAP message and receive a reply, invoke SOAPConnection 's
SOAPMessage call(SOAPMessage request, Object to) method. The
specified request message is sent to the endpoint identified by to , which may be
a String or URL instance. This method throws SOAPException when a SOAP
problem occurs, and blocks until it receives a SOAP message, which it returns as a
SOAPMessage object. The following example provides a demonstration:
String endpoint = "http://tutortutor.ca/library/gettitle";
// Send the request message identified by soapm to the web
service at the specified
// endpoint and return the response message.
SOAPMessage response = soapc.call(soapm, endpoint);
Alternatively, you can call SOAPConnection 's SOAPMessage get(Object
to) methodtorequestaSOAPmessage.Aswith call() , get() blocksuntilthere
is a reply, and throws SOAPException when a SOAP problem occurs.
Afterfinishingyour call() and/or get() invocations,call SOAPConnection 's
void close() method to close the connection to the endpoint. If this method has
already been called, a subsequent attempt to close the connection results in a thrown
SOAPException instance.
Roman Numerals and SAAJ
TodemonstrateSAAJinamorepracticalcontext,I'vecreateda RomanNumerals ap-
plicationthatusesthisAPItocommunicatewithaSOAP-basedRomanNumeralsCon-
versionwebservice,whichconvertsbetweenRomannumeralsandbase-10integerval-
ues.Thiswebservice'sWSDLdocumentislocatedat http://www.ebob42.com/
cgi-bin/Romulan.exe/wsdl/IRoman , and appears in Listing 11-17 .
Listing 11-17. WSDL for the Roman numerals/base-10 integer values conversion web service.
Search WWH ::




Custom Search