code: public String marshalObject(Object message)
      {
          try {
              IBindingFactory jc = BindingDirectory.getFactory(Model.class);
              IMarshallingContext marshaller = jc.createMarshallingContext();
              ByteArrayOutputStream out = new ByteArrayOutputStream();
              marshaller.setIndent(2);
              marshaller.marshalDocument(message, URL_ENCODING, null, out);
              String xml = out.toString(STRING_ENCODING);
              return xml;
          } catch (UnsupportedEncodingException e) {
              e.printStackTrace();
          } catch (JiBXException e) {
              e.printStackTrace();
          }
          return null;
      }
docs: Marshal this object to an XML string
  @param message
  @return.