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.

 View Only
  • 1.  Create Custom Java Service

    Posted Tue April 20, 2010 12:02 AM

    I am trying to create a generic Java Service that would takes a document as input and the output would be a propertySet. In my Java Service what would the code look like to take any document as input and loop over its elements to get the field and field value so I can create a propertyset?


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


  • 2.  RE: Create Custom Java Service

    Posted Tue April 20, 2010 06:48 AM

    If you are looking for the code for pipeline read/write then one of the easiest way is to create a dummy flow service with your required input/output structures and use
    Tools–> Generate Code to Implement this service Selecting Java as the lang, it will generate the required lines of code to read/write the input structures and will copy the code to the memory that u can then paste it to ur java service.


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


  • 3.  RE: Create Custom Java Service

    Posted Tue April 20, 2010 04:15 PM

    I am looking for the code that will loop over the elements in a document to get the field and field value so I can create a propertyset.


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


  • 4.  RE: Create Custom Java Service

    Posted Tue April 20, 2010 05:57 PM

    Here is the solution to my problem if anyone is interested. The service takes a document as the input and the output is a propertySet.

    //Convert document to PropertySet
    // pipeline
    IDataCursor pipelineCursor = pipeline.getCursor();
    // Get document
    Object document = IDataUtil.getIData( pipelineCursor, “document” );
    IData doc = (IData)document;
    IDataCursor docCursor = doc.getCursor();
    String element = new String();
    String value = new String();

    Properties properties = new Properties();
    docCursor.first();
    while(docCursor.next()) // get name value pair for each element in the record
    {
    element = docCursor.getKey();
    value = IDataUtil.getString(docCursor,element);
    properties.setProperty(element, value);
    }

    docCursor.destroy();

    pipelineCursor.destroy();
    // pipeline
    IDataCursor pipelineCursor_1 = pipeline.getCursor();
    Object propertySet = new Object();
    IDataUtil.put( pipelineCursor_1, “propertySet”, properties );
    pipelineCursor_1.destroy();


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