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.  Zip file java service

    Posted Wed September 01, 2010 11:07 PM

    Can anyone tell me what I ma doing wrong. Service compiles fine but does not give any result.

    IDataCursor pipelineCursor = pipeline.getCursor();
    byte[] zippedBytes = null;
    ZipInputStream zippedStream = null;
    String fname = "super";
    ZipEntry ze = null;
    IData[] data = new IData[5];
    int temp  = 0;
    
    if (pipelineCursor.first("zipbytes"))
    {
    zippedBytes = (byte[])pipelineCursor.getValue();
    }
    else
    throw new ServiceException("Missing required parameter");
    if (pipelineCursor.first("zipfilename"))
    fname = (String) pipelineCursor.getValue();
    ByteArrayInputStream is = new ByteArrayInputStream(zippedBytes);
    try{
    zippedStream = new ZipInputStream(is);
    }
    catch (Exception e)
    {
    throw new ServiceException(e.getMessage());
    }
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    int dataSize = 0;
    try
    {
    while ((ze = zippedStream.getNextEntry()) != null)
    {     
    String strUnzippedFileName = ze.getName();
    int numBytesRead = 0;
    byte rdata[] = new byte[4096];
    Object unZippedBytes;
    while ((numBytesRead = zippedStream.read(rdata)) != -1)
    {
    try 
    {
    numBytesRead = zippedStream.read(rdata);
    }
    catch (EOFException e)
    {
    numBytesRead = -1;        
    }
    os.write(rdata, 0, numBytesRead);
    }
    unZippedBytes = os.toByteArray();
    
    data[dataSize] = IDataFactory.create();
    IDataCursor outDataCursor = data[dataSize].getCursor();
    Object bytes = unZippedBytes;
    String filename  = strUnzippedFileName;
    IDataUtil.put(outDataCursor, "bytes", bytes);
    IDataUtil.put(outDataCursor, "filename", filename);
    dataSize++;
    outDataCursor.destroy();
    }
    }
    catch (IOException e)
    {
    throw new ServiceException("Exception occurred while handling ZIP file: " + e);
    }
    
    

    Inputs is: zippedBytes which is an object and filename.

    Output is a datalist of the unzipped contents - bytes, filename
    regards,
    qwerty12


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


  • 2.  RE: Zip file java service

    Posted Thu September 02, 2010 12:59 AM

    You’re not putting the data into the pipeline. Need to add

    IDataUtil.put(pipelineCursor, “datalist”, data);
    pipelineCursor.destroy();


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


  • 3.  RE: Zip file java service

    Posted Thu September 02, 2010 11:16 PM