public static String serviceConfigToXml(final ServiceConfig serviceConfig) throws CodeGenFailedException { final StringWriter writer = new StringWriter(); try { final JavaXmlBinder javaXmlBinder = JavaXmlBindingFactory.getInstance(); javaXmlBinder.generateServiceConfigXml(serviceConfig, writer); } catch (final Exception ex) { throw new CodeGenFailedException("Failed to generate Service Config xml file", ex); } return writer.toString(); }
public static void generateServiceConfigXml( ServiceConfig serviceConfig, String destLoc, String configFileName) throws CodeGenFailedException { Writer fileWriter = null; try { fileWriter = CodeGenUtil.getFileWriter(destLoc, configFileName); JavaXmlBinder javaXmlBinder = JavaXmlBindingFactory.getInstance(); javaXmlBinder.generateServiceConfigXml(serviceConfig, fileWriter); } catch (Exception ex) { throw new CodeGenFailedException("Failed to generate Service Config xml file", ex); } finally { CodeGenUtil.closeQuietly(fileWriter); } }