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.  Convert BLOB to file

    Posted Wed September 25, 2002 11:46 PM

    I’m reading a BLOB from a db column and it ends up in the results output of the query method. The BLOB is contained in a T/String wm type. It appears to be base64 encoded but I’m not sure …

    Has anyone successfully taking that String and actually written it to a filesystem in its native format so it can be viewed?

    Here is what I tried:

    1. Took the string and pub.string:base64decoded it into a byte type.
    2. Sent it to a Java service that executed the following code:

    IDataHashCursor pipelineCursor = pipeline.getHashCursor();

    pipelineCursor.first( “pathToFile” );
    String pathToFile = (String) pipelineCursor.getValue();

    pipelineCursor.first( “bytes” );
    Object bytes = pipelineCursor.getValue();

    try{
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(baos);
    oos.writeObject(bytes);
    byte theObjectBytes = baos.toByteArray();
    File f = new File(pathToFile);
    FileOutputStream fos = new FileOutputStream(f);
    fos.write(theObjectBytes);
    fos.close();
    }catch (Exception e){
    System.out.println(e);
    }

    but unfortunantly it was mangled. Any thoughts on whats going on?


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


  • 2.  RE: Convert BLOB to file

    Posted Thu September 26, 2002 04:19 AM

    It may be worthwile inserting a text string as BLOB data in your DB. Then try reading the BLOB and running the output of base64decode to pub.string:bytesToString to see if its what you expected.

    > appears to be base64 encoded but I’m not sure …

    I think base64 data encoded by WM ends with a “==”.

    Hope that helps!
    Sonam


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


  • 3.  RE: Convert BLOB to file

    Posted Thu September 26, 2002 04:17 PM

    Right on, thanks for the tip. I’ll try that out.


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


  • 4.  RE: Convert BLOB to file

    Posted Thu September 26, 2002 06:38 PM

    Mike, are you using webMethods IS to insert the BLOB into the database, too? We had some issues getting that done and were told by webMethods that BLOB data can be read but not written.


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


  • 5.  RE: Convert BLOB to file

    Posted Thu September 26, 2002 11:41 PM

    Hmm, at some point we will be inserting BLOBs, but at this point its only reading…

    I too have heard from WM that its not trivial to write BLOBs and heard something along the lines of having to write JDBC calls directly in a Java flow script.

    Mike


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