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.



#Automation


#Applicationintegration
#webMethods
#Integration
 View Only
  • 1.  An array of IData objects

    Posted 07/31/10 05:39 PM

    Hi

    I have created a simple java service that will invoke a built-in java service “pub.date.dateTimeFormat”.
    I declared a DocumentList(named “date”) having “inString”, “currentPattern”, “newPattern” as fields in DocumentList.
    And also another DocumentList(named “dateOut”) having “value” as a field.

    Any way i developed the code and it is working properly.
    And my doubt is:
    “is it the correct way to create an array of IData objects and is there any better approach to do so?”
    Here is my code…

    // pipeline
    IDataCursor pipelineCursor = pipeline.getCursor();

    // date
    IData[]    date = IDataUtil.getIDataArray( pipelineCursor, "date" );
    int n=date.length;
    
    IData out[] = new IData[n];// can we create IData objects like this?
    String output[] =new String[n];
    if ( date != null)
    {        
    for ( int i = 0; i < date.length; i++ )
    {
    try{
    out[i] = Service.doInvoke("pub.date","dateTimeFormat", date[i]);
    }catch(Exception ex){}
    }
    }
    pipelineCursor.destroy();
    
    for ( int i = 0; i <out.length; i++ ) 
    {
    IDataCursor outCursor = out[i].getCursor();
    output[i] = IDataUtil.getString( outCursor, "value" );
    outCursor.destroy();
    }
    

    // pipeline
    IDataCursor pipelineCursor_1 = pipeline.getCursor();

    // dateOut
    IData[]    dateOut = new IData[n];
    for ( int i = 0; i <dateOut.length; i++ ) 
    {
    dateOut[i] = IDataFactory.create();
    IDataCursor dateOutCursor = dateOut[i].getCursor();
    IDataUtil.put( dateOutCursor, "value", output[i] );
    dateOutCursor.destroy();
    }
    

    IDataUtil.put( pipelineCursor_1, “dateOut”, dateOut );
    pipelineCursor_1.destroy();

    Thanks in advance…
    Trinadh


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


  • 2.  RE: An array of IData objects

    Posted 07/31/10 10:17 PM

    I would suggest doing this with flow service. Java is not necessary for this.


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


  • 3.  RE: An array of IData objects

    Posted 08/02/10 09:25 PM

    I’m 100% with you. for most of the tasks using already built-in services should resolve it, and Java code SHOULD be used for very few particular things.

    However for learning purposes it’s fine this kind of code :smiley:


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