Writing in file .xml

Hello,
I’m very new at this from the WM, I am working with the Developer, and I’m making some transformations of an XML format to another new format, what I want to know is how physically write to a file. Xml with the document generated with The new format, or modify and update its contents (of the file. xml) with the document and its new format.

I show them the screens of my service flow
Nissan.jpg
nissan2.jpg

Hi,
U can write the newly formed xml into a file using the PS utilities. u can get this package from the advantage site. By default the PS utilities write the files into the indegration folder. If u want to write to your mentioned folder or directory, add teh path in utilitie config file

Thanks for your answer, but from where I get these Utilities PS, I’m new in WM and no where is this tool that I mention, if you could please tell me where he is, is a flow service or that is?

Thanks for your answer, but from where I get these Utilities PS, I’m new in WM and no where is this tool that I mention, if you could please tell me where he is, is a flow or service that is?

Ok U will get this package from the www.advantage.webmethods.com

Just search for PSutilities. BUt remember whne ever u change the config file u need to load the file from the developer…no need to restart the IS.

You can write your own java service to write to a file.

Example -

Java Service name - writeToFile

Inputs - userData, filename, appendOverwriteFlag

Code -

IDataCursor idcPipeline = pipeline.getCursor();
String strUserData = null;
String strFullFilename = null;
if (idcPipeline.first(“userData”))
{
strUserData = (String)idcPipeline.getValue();
}
if (idcPipeline.first(“filename”))
{
strFullFilename = (String)idcPipeline.getValue();
}
else
{
throw new ServiceException(“filename is null!” );
}
idcPipeline.first(“appendOverwriteFlag”);
String appendOverwriteFlag = (String)idcPipeline.getValue();

// Separate filename into path and filename
// This is done so that the directory can be written (if necessary)
String separator = System.getProperty(“file.separator”);
int indexSeparator = strFullFilename.lastIndexOf(separator);
if (indexSeparator == -1)
{
// Account for fact that you can use either ‘' or ‘/’ in Windows
indexSeparator = strFullFilename.lastIndexOf(’/');
}
String strPathName = strFullFilename.substring(0, indexSeparator+1);
String strFileName = strFullFilename.substring(indexSeparator+1);

FileWriter fw = null;
try
{
File pathToBeWritten = new File(strPathName);
// System.out.println("canonical path = " + pathToBeWritten.getCanonicalPath());

// Write the directory...
if (pathToBeWritten.exists() == false)
{
  throw new ServiceException("Path does not exist!");
}

// Check if file exists
File fileToBeWritten = new File(strFullFilename);
if (fileToBeWritten.exists() == true && appendOverwriteFlag != null && appendOverwriteFlag.equals("failIfFileExists"))
{
  throw new ServiceException("File " + strFullFilename + " already exists!");
}

// Write the file...
if (appendOverwriteFlag != null && appendOverwriteFlag.equals("overwrite"))
{
  // overwrite
  fw = new FileWriter(strFullFilename, false);

}
else
{
  // append
  fw = new FileWriter(strFullFilename, true);

}
fw.write(strUserData);

}
catch (Exception e)
{
throw new ServiceException(e.getMessage());
}
finally
{
// Close the output stream…
try
{
fw.close();
}
catch (Exception e)
{}

idcPipeline.destroy();

}

Thanks for your answer, a question which is the function of these variables: UserData, filename, appendOverwriteFlag, who served for each of them?, If you could please explain.

Thank you for your attention.