Client Usage

The JiBX/WS client implementation uses a simple message exchange pattern. This is implemented in protocol specific subclasses of the Client class. You specify the target service access location when you create an instance of these classes, along with the JiBX binding factory for the bindings used by the web service, and, optionally, with options specifying the encoding and format of the output. Once the instance has been created, you use the call() method to actually invoke the service. Here's an example:

    // initialize SOAP client for service
    IBindingFactory fact = BindingDirectory.getFactory(Query.class);
    Client client = new SoapClient("http://localhost:8080/jibxws/quake", fact);
    // set up the query and pass in call to server
    Query query = new Query();
    Response response = (Response);

This accesses a service located at http://localhost:8080/jibxws/quake. Since JiBX/WS is intended only for doc/lit web services, the operation to be performed by the service is always determined by the root element of the request body. With JiBX/WS the request body is generated by marshalling out the object supplied to the method using the binding configured when the Client instance is created. The response message body is unmarshalled to create an object, which is then returned by the method.

The constructor takes a single binding factory parameter since it is expected that a single binding definition would define the bindings for all request and response objects, and for any SOAP Fault details objects. If this is not the case, the client includes separate methods for setting the binding factory for each of the request, response and SOAP body objects.

The SoapClient also include options to set SOAP headers, add SOAP header handlers and set SOAP Fault handlers.

Rather than specifying a concrete Client subclass, you can use the Protocol.createClient() method. This allows the same client code to be used with different protocols. See the Seismic example application for an example of this approach.

The default for output XML generated by the client is to use a UTF-8 text encoding without added spaces or line breaks. You can alter these settings using the MessageOptions parameter to the Client constructor.

The current main client limitation is the restriction to a simple generic call() method that takes a java.lang.Object parameter as input and returns another as the response. Code generation for a client proxy class to act as a convenient interface for wrapped style services (with multiple parameters) may be added in the future.

Spring usage

No special support is currently included for using the Spring Framework on the client side. The JiBX/WS client can be configured using Spring, as shown in the Spring Hello World example.