| This class provides a simple web service client capable of leveraging
Javolution
javolution.xml XML marshalling/unmarshalling .
Sub-classes may work from WSDL files,
javolution.xml.XMLFormatXMLFormat or directly with the XML streams (StAX). For example:[code]
private static class HelloWorld extends WebServiceClient {
protected void writeRequest(XMLObjectWriter out) throws XMLStreamException {
XMLStreamWriter xml = out.getStreamWriter();
xml.writeDefaultNamespace("http://www.openuri.org/");
xml.writeEmptyElement("helloWorld"); // Operation name.
}
protected void readResponse(XMLObjectReader in) throws XMLStreamException {
XMLStreamReader xml = in.getStreamReader();
xml.require(START_ELEMENT, "http://www.openuri.org/", "string");
xml.next(); // Move to character content.
System.out.println(xml.getText());
}
}
WebServiceClient ws = new HelloWorld().setAddress("http://acme.com:80/HelloWorld.jws");
ws.invoke();
> Hello World!
[/code]
Note: At this moment, this class is supported only on the J2SE
platform. Soon, it will also be supported on mobile devices
through the CLDC/MIDP Generic Connection framework.
author: Jean-Marie Dautelle version: 5.2, September 16, 2007 |