code: public static byte[] serializeToByteArray(final ServiceProperties properties) throws IllegalArgumentException,
              IllegalStateException, IOException {
          final StringWriter outWriter = new StringWriter();
          final XmlSerializer xmlw = Utility.getXmlSerializer(outWriter);
  
          // default is UTF8
          xmlw.startDocument(Constants.UTF8_CHARSET, true);
          xmlw.startTag(Constants.EMPTY_STRING, Constants.AnalyticsConstants.STORAGE_SERVICE_PROPERTIES_ELEMENT);
  
          if (properties.getLogging() != null) {
              // Logging Properties
              writeLoggingProperties(xmlw, properties.getLogging());
          }
  
          if (properties.getHourMetrics() != null) {
              // Hour Metrics
              writeMetricsProperties(xmlw, properties.getHourMetrics(), Constants.AnalyticsConstants.HOUR_METRICS_ELEMENT);
          }
  
          if (properties.getMinuteMetrics() != null) {
              // Minute Metrics
              writeMetricsProperties(xmlw, properties.getMinuteMetrics(),
                      Constants.AnalyticsConstants.MINUTE_METRICS_ELEMENT);
          }
  
          if (properties.getCors() != null) {
              // CORS Properties
              writeCorsProperties(xmlw, properties.getCors());
          }
  
          // Default Service Version
          if (properties.getDefaultServiceVersion() != null) {
              Utility.serializeElement(xmlw, Constants.AnalyticsConstants.DEFAULT_SERVICE_VERSION,
                      properties.getDefaultServiceVersion());
          }
  
          // end StorageServiceProperties
          xmlw.endTag(Constants.EMPTY_STRING, Constants.AnalyticsConstants.STORAGE_SERVICE_PROPERTIES_ELEMENT);
  
          // end doc
          xmlw.endDocument();
  
          return outWriter.toString().getBytes(Constants.UTF8_CHARSET);
      }
docs: Writes the contents of the ServiceProperties to the stream in xml format.
  
  @return a byte array of the content to write to the stream.
  @throws IOException
  if there is an error writing the service properties.
  @throws IllegalStateException
  if there is an error writing the service properties.
  @throws IllegalArgumentException
  if there is an error writing the service properties.