IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.


#TechXchangePresenter
 View Only
Expand all | Collapse all

write data into local file system

webMethods Community Member

webMethods Community MemberTue December 11, 2012 05:14 PM

  • 1.  write data into local file system

    Posted Thu April 30, 2009 02:09 PM

    Hi Reamon,

    Will you please tell me that which developer service i can use to write data into local file system. e.g. file IO in java. I want to write some data in text file or xml file using IS service.

    Thanks
    AShah


    #Integration-Server-and-ESB
    #Flow-and-Java-services
    #webMethods


  • 2.  RE: write data into local file system

    Posted Thu April 30, 2009 04:48 PM

    Such a service is not provided in a standard installation.

    The PSUtilities package, which can be downloaded from Advantage, has several IO related services including several that write to a file.


    #Flow-and-Java-services
    #webMethods
    #Integration-Server-and-ESB


  • 3.  RE: write data into local file system

    Posted Wed June 03, 2009 12:49 PM

    Hello Reamon,

    I searched for the PSUtilties package on advantage site but was unable to locate it. I am using WM 7.1.2 version.

    Can you please let me know the download link for PSUtilities package?

    THanks,


    #Flow-and-Java-services
    #webMethods
    #Integration-Server-and-ESB


  • 4.  RE: write data into local file system



  • 5.  RE: write data into local file system

    Posted Thu June 04, 2009 06:17 AM

    You can write simple Java service to do so. A simple program -

    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();

    }


    #Flow-and-Java-services
    #webMethods
    #Integration-Server-and-ESB


  • 6.  RE: write data into local file system

    Posted Mon November 21, 2011 05:58 PM

    use streamtofile service from PSUtils. on the input set it to be the full path name where you wnat to save your file. also add that dir to the allowed dirs on the config of the PSUtil package.

    Cheers


    #Integration-Server-and-ESB
    #Flow-and-Java-services
    #webMethods


  • 7.  RE: write data into local file system

    Posted Mon December 10, 2012 04:57 PM

    Hellow,

    The java service throwing the service exception " path does not exist"
    How can i rectify the exception and execute the java service

    Thanks,

    S Banu Prakash


    #webMethods
    #Integration-Server-and-ESB
    #Flow-and-Java-services


  • 8.  RE: write data into local file system

    Posted Mon December 10, 2012 06:28 PM

    Did you check the path to access? Is it a full absolute path you have given accessible to IS?


    #webMethods
    #Integration-Server-and-ESB
    #Flow-and-Java-services


  • 9.  RE: write data into local file system

    Posted Tue December 11, 2012 11:48 AM

    What are the inputs required to execute the above service and how can we map the elements in the pipeline.


    #webMethods
    #Integration-Server-and-ESB
    #Flow-and-Java-services


  • 10.  RE: write data into local file system

    Posted Tue December 11, 2012 05:05 PM

    I’m just guessing but I think it is saying that the directory path you’re trying to write to does not exist on the server. :slight_smile:


    #Flow-and-Java-services
    #webMethods
    #Integration-Server-and-ESB


  • 11.  RE: write data into local file system

    Posted Tue December 11, 2012 05:08 PM

    Is the directory path should present in the directory in which we installed webMethods or we may specify any directory in the system

    Thanks,

    Banu Prakash


    #Integration-Server-and-ESB
    #webMethods
    #Flow-and-Java-services


  • 12.  RE: write data into local file system

    Posted Tue December 11, 2012 05:14 PM


  • 13.  RE: write data into local file system

    Posted Tue December 11, 2012 05:16 PM

    Thanks for your clarification

    Thanks,

    Banu Prakash


    #Integration-Server-and-ESB
    #webMethods
    #Flow-and-Java-services


  • 14.  RE: write data into local file system

    Posted Tue December 11, 2012 05:17 PM

    The answer to your inputs question is in the code. Please review to see if you can determine the inputs needed. If afterwards you’re still stuck post your specific question.


    #webMethods
    #Flow-and-Java-services
    #Integration-Server-and-ESB


  • 15.  RE: write data into local file system

    Posted Tue December 11, 2012 05:20 PM

    Did you check this first thing “path does not exist”?

    HTH,
    RMG


    #Flow-and-Java-services
    #webMethods
    #Integration-Server-and-ESB


  • 16.  RE: write data into local file system

    Posted Tue December 11, 2012 05:24 PM

    I tried to run with Psutilities\file\writeToFile

    and provided inputs filename as *C:\sample\test\error.txt
    and map userdata that we want to store in the file, but the txt file on running service does not store any information.

    any one help on this issue


    #Integration-Server-and-ESB
    #Flow-and-Java-services
    #webMethods


  • 17.  RE: write data into local file system

    Posted Tue December 11, 2012 06:12 PM

    It is written on the IS server, not on your computer.

    Also, if you use the PSUtilities services they have a configuration file which is used to control which directories are accessible. You’ll need to update the configuration. Refer to the docs in PSUtilities. Or use a different service.


    #webMethods
    #Integration-Server-and-ESB
    #Flow-and-Java-services


  • 18.  RE: write data into local file system

    Posted Tue December 11, 2012 06:15 PM

    I have psutilities , so how can I save pipeline to file by using writeToFile

    Thanks,

    Banu


    #Integration-Server-and-ESB
    #webMethods
    #Flow-and-Java-services


  • 19.  RE: write data into local file system

    Posted Tue December 11, 2012 06:20 PM

    You save pipeline to file by using savePipelineToFile. You wouldn’t use writeToFile for that.

    I would also encourage not using PSUtilities directly. Copy the services you want to use to your own utilities or “public” package.

    If you’re using version 8 and have a need to write your own data to a file, pub.file now has services to write to a file.


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 20.  RE: write data into local file system

    Posted Tue December 11, 2012 06:26 PM

    My requirement in the project is I need to map the error information to a document and then saving the document to a file , through which we can refer the error information, So, that I tried to use the Psutilities\file\writeToFile service.

    If we use SavePipelineToFile then the same thing can be achieved.

    Thanks in advonce,

    S Banu Prakash


    #Integration-Server-and-ESB
    #Flow-and-Java-services
    #webMethods


  • 21.  RE: write data into local file system

    Posted Tue December 11, 2012 06:46 PM

    SavePipelineToFile is for another purpose for debugging flow/pipeline runtime needs etc…

    So do you want to save pipeline data or some interface/application data to be written/store to a file?

    Regarding PSUtilities package you also need to update the config file and read/write permissions to the particular folder you are trying to save the file needs to be configured.

    HTH,
    RMG


    #Flow-and-Java-services
    #webMethods
    #Integration-Server-and-ESB


  • 22.  RE: write data into local file system

    Posted Tue December 11, 2012 06:51 PM

    So, How can I save variables into a file by using writeToFile in specified location.
    I had prepared flow service, and invoked writeToFlow in the flow and map the document to the Userdata and specify the path in the filename.

    On running the interface the variables are not saving into the specified location
    Will any one help in this issue.

    thanks in advance

    Banu Prakash


    #Flow-and-Java-services
    #webMethods
    #Integration-Server-and-ESB


  • 23.  RE: write data into local file system

    Posted Tue December 11, 2012 07:00 PM

    For pipeline variables/debugging purpose - savePipelineToFile (just map filename)

    A files will be stored in the IntegrationServer/pipeline folder

    Use the restorePipelineFromFile (give same filename from save) to interospect the runtime pipeline vars

    If this is what you are expecting?

    HTH,
    RMG


    #Integration-Server-and-ESB
    #webMethods
    #Flow-and-Java-services


  • 24.  RE: write data into local file system

    Posted Sun April 12, 2020 02:23 AM

    Hi All,

    I retrieved data from database and and I need to write the retrieved data into local XML file.

    How to do that?

    What are the in-built services are to be used?

    What are the properties?

    Please help me with step by step process.

    Thanks.


    #Integration-Server-and-ESB
    #Flow-and-Java-services
    #webMethods