### XFire Home Bug/Issue Reporting Download FAQ Get Involved License News Stack Comparison Support User's Guide XFire Team ### M5 Javadocs Reports ### M6-SNAPSHOT Javadocs Reports ### Developers Developer Space CVS Building Architecture Interesting Projects Release Process | ## Client Overview The XFire Core contains classes which function as SOAP and REST clients. Currently there is only a prebundled client for the XMLBeans module. You can use this client via the API and you can also generate a client from a WSDL file. To learn more see section on [XMLBeans Client Generator]. If you wish to use the SOAP/REST clients without XMLBeans, read on to learn how to create a ClientHandler of your own. ## Writing a ClientHandler A ClientHandler generates a request and parses a response. You pass this handler to the SoapClient constructor. When the service is invoked() it will delegate the generation of the SOAP Body request and parsing of the response Body to your handler. For instance:
    YourHandler handler = new YourHandler();
    SoapHttpClient client = new SoapHttpClient(handler);
    client.setServiceUrl("http://some.service.com");

    client.invoke();
A client handler must implement the following interface:
    public class ObjectHandler
        implements ClientHandler
    {
        private Object request;
        private Object response;

        public boolean hasRequest()
        {
            return true;
        }

        public void writeRequest(XMLStreamWriter writer) throws XMLStreamException
        {
            serialize(request, writer);
        }

        protected void serialize(Object request2, XMLStreamWriter writer)
        {
            // TODO
        }

        public void handleResponse(XMLStreamReader reader) throws XMLStreamException
        {
            response = deserialize(reader);
        }

        private Object deserialize(XMLStreamReader reader)
        {
            // TODO
            return null;
        }

        public Object getRequest()
        {
            return request;
        }

        public void setRequest(Object request)
        {
            this.request = request;
        }

        public Object getResponse()
        {
            return response;
        }

        public void setResponse(Object response)
        {
            this.response = response;
        }
    }
The above is pretty straight forard. We are serializing the request object and deserializing the respone object. To use this handler, it would look something like this:
    ObjectHandler handler = new ObjectHandler ();
    SoapHttpClient client = new SoapHttpClient(handler);
    client.setServiceUrl("http://some.service.com");

    handler.setRequest( yourRequestObject );
    client.invoke();

    Object response = handler.getResponse();