Java Reference
In-Depth Information
}
String toInteger(String input) throws SOAPException
{
// Build a request message. The first step is to cre-
ate an empty message
// via a message factory. The default SOAP 1.1 mes-
sage factory is used.
MessageFactory
mfactory
=
MessageFact-
ory.newInstance();
SOAPMessage request = mfactory.createMessage();
// The request SOAPMessage object contains a SOAPPart
object, which
// contains a SOAPEnvelope object, which contains an
empty SOAPHeader
// object followed by an empty SOAPBody object.
// Detach the header since a header is not required.
This step is
// optional.
SOAPHeader header = request.getSOAPHeader();
header.detachNode();
// Access the body so that content can be added.
SOAPBody body = request.getSOAPBody();
// Add the RomanToInt operation body element to the
body.
QName bodyName = new QName("http://ebob42.org/", "ro-
mantoint", "tns");
SOAPBodyElement
bodyElement
=
body.addBodyElement(bodyName);
// Add the Rom child element to the RomanToInt body
element.
QName name = new QName("rom");
SOAPElement
element
=
bodyEle-
ment.addChildElement(name);
element.addTextNode(input).setAttribute("xsi:type",
"xs:string");
// Add appropriate namespaces and an encoding style
Search WWH ::




Custom Search