java service to save xml string to File

Can anyone help me out in creating a java service to save xml string to File.

If you are in 8.x version, there is a service called pub.file:stringToFile which will do what you want.

-Senthil

if you have PSUtilities package below service can be use to save to file

PSUtilities.file:writeToFile

To use the pub.file:stringToFile in 8.x, the file path trying to save to has to be specified in the [FONT=PalatinoLinotype-Roman][SIZE=3][FONT=PalatinoLinotype-Roman][SIZE=3]

“allowedWritePaths” values specified in the FileAccessControl [SIZE=2][FONT=arial]configuration file, could not find the FileAccessControl File either anywhere in the IS directory. For now created a java service using BufferedWriter -

String statusFlag = “false”;
BufferedWriter fileWriter = null;
try
{
fileWriter = new BufferedWriter(new FileWriter(fileName));
fileWriter.write(xmlData);
statusFlag = “true”;
} catch(Exception e) {e.printStackTrace();}
finally { //Close the BufferedWriter
try {
if (fileWriter != null)
{
fileWriter.flush();
fileWriter.close();
}
} catch (IOException ex) {ex.printStackTrace(); }
}
[/font][/size][/SIZE][/FONT][/SIZE][/FONT]

/IntegrationServer/packages/WmPublic/config/fileAccessControl.cnf is the File to edited, with the File paths which to be edited.

Hello,

when i used the service pub.file:stringToFile I am getting the below error eventhough I have added the paths in /IntegrationServer/packages/WmPublic/config/fileAccessControl.cnf :

com.wm.app.b2b.server.ServiceException: java.io.IOException: The filename, directory name, or volume label syntax is incorrect

com.wm.app.b2b.server.ServiceException: java.io.IOException: The filename, directory name, or volume label syntax is incorrect
at pub.file.checkPathValidity(file.java:140)
at pub.file.readerToFile(file.java:156)
at pub.file.stringToFile(file.java:857)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.wm.app.b2b.server.JavaService.baseInvoke(JavaService.java:439)
at com.wm.app.b2b.server.invoke.InvokeManager.process(InvokeManager.java:643)
at com.wm.app.b2b.server.util.tspace.ReservationProcessor.process(ReservationProcessor.java:46)
at com.wm.app.b2b.server.invoke.StatisticsProcessor.process(StatisticsProcessor.java:44)
at com.wm.app.b2b.server.invoke.ServiceCompletionImpl.process(ServiceCompletionImpl.java:243)
at com.wm.app.b2b.server.invoke.ValidateProcessor.process(ValidateProcessor.java:51)
at com.wm.app.b2b.server.invoke.PipelineProcessor.process(PipelineProcessor.java:171)
at com.wm.app.b2b.server.ACLManager.process(ACLManager.java:276)
at com.wm.app.b2b.server.invoke.DispatchProcessor.process(DispatchProcessor.java:30)
at com.wm.app.b2b.server.AuditLogManager.process(AuditLogManager.java:363)
at com.wm.app.b2b.server.invoke.InvokeManager.invoke(InvokeManager.java:547)
at com.wm.app.b2b.server.invoke.InvokeManager.invoke(InvokeManager.java:386)
at com.wm.app.b2b.server.ServiceManager.invoke(ServiceManager.java:234)
at com.wm.app.b2b.server.BaseService.invoke(BaseService.java:194)
at com.wm.lang.flow.FlowInvoke.invoke(FlowInvoke.java:324)
at com.wm.lang.flow.FlowState.invokeNode(FlowState.java:584)
at com.wm.lang.flow.FlowState.step(FlowState.java:444)
at com.wm.lang.flow.FlowState.invoke(FlowState.java:409)
at com.wm.app.b2b.server.FlowSvcImpl.baseInvoke(FlowSvcImpl.java:1057)
at com.wm.app.b2b.server.invoke.InvokeManager.process(InvokeManager.java:643)
at com.wm.app.b2b.server.util.tspace.ReservationProcessor.process(ReservationProcessor.java:46)
at com.wm.app.b2b.server.invoke.StatisticsProcessor.process(StatisticsProcessor.java:44)
at com.wm.app.b2b.server.invoke.ServiceCompletionImpl.process(ServiceCompletionImpl.java:243)
at com.wm.app.b2b.server.invoke.ValidateProcessor.process(ValidateProcessor.java:51)
at com.wm.app.b2b.server.invoke.PipelineProcessor.process(PipelineProcessor.java:171)
at com.wm.app.b2b.server.ACLManager.process(ACLManager.java:276)
at com.wm.app.b2b.server.invoke.DispatchProcessor.process(DispatchProcessor.java:30)
at com.wm.app.b2b.server.AuditLogManager.process(AuditLogManager.java:363)
at com.wm.app.b2b.server.invoke.InvokeManager.invoke(InvokeManager.java:547)
at com.wm.app.b2b.server.invoke.InvokeManager.invoke(InvokeManager.java:386)
at com.wm.app.b2b.server.ServiceManager.invoke(ServiceManager.java:234)
at com.wm.app.b2b.server.comm.DefaultServerRequestHandler.handleMessage(DefaultServerRequestHandler.java:119)
at com.wm.app.b2b.server.HTTPMessageHandler.process(HTTPMessageHandler.java:160)
at com.wm.app.b2b.server.HTTPDispatch.handleRequest(HTTPDispatch.java:181)
at com.wm.app.b2b.server.Dispatch.run(Dispatch.java:355)
at com.wm.util.pool.PooledThread.run(PooledThread.java:131)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.io.IOException: The filename, directory name, or volume label syntax is incorrect
at java.io.WinNTFileSystem.canonicalize0(Native Method)
at java.io.Win32FileSystem.canonicalize(Win32FileSystem.java:396)
at java.io.File.getCanonicalPath(File.java:559)
at java.io.File.getCanonicalFile(File.java:583)
at pub.file.checkPathValidity(file.java:129)

Could you please let me know what the issue might be… I am giving the file name as C:\SoftwareAG\IntegrationServer\pipeline\FlatFile.txt.

Thanks
Nikhil

Try the solution mentioned in the thread - error while using pub.file:stringToFile in webMethods 8.2