Overview | Package | Class | Tree | Deprecated | Index | Help
| J avolution v5.3 (J2SE 1.5+)
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## javolution.xml.ws
Class WebServiceClient

    java.lang.Object
      javolution.xml.ws.WebServiceClient

    public abstract class WebServiceClient

extends java.lang.Object

This class provides a simple web service client capable of leveraging Javolution `XML marshalling/unmarshalling`.

Sub-classes may work from WSDL files, `XMLFormat` or directly with the XML streams (StAX). For example:``

         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!

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.

Version:
  5.2, September 16, 2007
Author:
  Jean-Marie Dautelle

Field Summary
`static java.lang.String` | `ENVELOPE_PREFIX` Holds standard SOAP envelope prefix.
`static java.lang.String` | `ENVELOPE_URI` Holds standard SOAP envelope namespace.

Constructor Summary
`WebServiceClient()` Default constructor (address not set).

Method Summary
`void` | `invoke()` Invokes the web service.
`protected void` | `readResponse(XMLObjectReader in)` Reads the web service response (SOAP body).
`WebServiceClient` | `setAddress(java.lang.String address)` Sets the address of this web service.
`protected abstract void` | `writeRequest(XMLObjectWriter out)` Writes the web service request (SOAP body).

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### ENVELOPE_PREFIX

    public static final java.lang.String ENVELOPE_PREFIX

  Holds standard SOAP envelope prefix.

  See Also:
    Constant Field Values

### ENVELOPE_URI

    public static final java.lang.String ENVELOPE_URI

  Holds standard SOAP envelope namespace.

  See Also:
    Constant Field Values

Constructor Detail

### WebServiceClient

    public WebServiceClient()

  Default constructor (address not set).

Method Detail

### setAddress

    public WebServiceClient setAddress(java.lang.String address)

  Sets the address of this web service.

  Parameters:
    `address` - the service full address.

### invoke

    public void invoke()
                throws java.io.IOException,
                       XMLStreamException

  Invokes the web service.

  Throws:
    `java.io.IOException`
    `XMLStreamException`

### writeRequest

    protected abstract void writeRequest(XMLObjectWriter out)
                                  throws XMLStreamException

  Writes the web service request (SOAP body).

  Parameters:
    `out` - the XML object writer.
  Throws:
    `XMLStreamException`

### readResponse

    protected void readResponse(XMLObjectReader in)
                         throws XMLStreamException

  Reads the web service response (SOAP body). The default implementation writes the body XML events to `System.out`.

  Parameters:
    `in` - the XML object reader.
  Throws:
    `XMLStreamException`

Overview | Package | Class | Tree | Deprecated | Index | Help
| J avolution v5.3 (J2SE 1.5+)
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2005 - 2009 Javolution.