public String buildServiceDocument() throws ODataRenderException {
  LOG.info("Building service(root) document");
  try (ByteArrayOutputStream outputStream=new ByteArrayOutputStream(BUFFER_SIZE)){
    XMLStreamWriter writer=startServiceDocument(outputStream);
    writeEntitySets(writer);
    writeSingleton(writer);
    endServiceDocument(writer);
    LOG.info("Successfully built service document");
    return outputStream.toString();
  }
 catch (  XMLStreamException|IOException e) {
    String msg="Something went wrong when writing service document.";
    LOG.error(msg,e);
    throw new ODataRenderException(msg,e);
  }
}

public String buildServiceDocument ( ) throws ODataRenderException { LOG . info ( "Building service(root) document" ) ; try ( ByteArrayOutputStream outputStream = new ByteArrayOutputStream ( BUFFER_SIZE ) ) { XMLStreamWriter writer = startServiceDocument ( outputStream ) ; writeEntitySets ( writer ) ; writeSingleton ( writer ) ; endServiceDocument ( writer ) ; LOG . info ( "Successfully built service document" ) ; return outputStream . toString ( ) ; } catch ( XMLStreamException | IOException e ) { String msg = "Something went wrong when writing service document." ; LOG . error ( msg , e ) ; throw new ODataRenderException ( msg , e ) ; } }
this is main method which generates service document .
