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.  XMLCoder

    Posted Thu December 05, 2002 09:44 PM

    Hello,

    I’m using IS 4.6… trying to develop some code in a java service to read an xml file and capture it as Values… here’s the sample code:

    XMLCoder txfilexml = new XMLCoder();

    FileInputStream txfile = new FileInputStream(“D:\B2B\Data\TXStatus.xml”);

    Values txvalues = txfilexml.decode(txfile);

    For some reason I’m getting an null pointer exception at the “Values” line…

    Any idea why?.. can anyone provide working sample code… just a simple conversion of an xml file to Values using java and the com.wm.util.coder.XMLCoder provided by webMethods…

    Thanks,
    Ken


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


  • 2.  RE: XMLCoder

    Posted Thu December 05, 2002 09:54 PM

    The xml file you using to decode has to be an encoded file (ie. not a normal xml file but a webMethods encoded XML file - you’ll see IData elements in the xml). You actually have to ENCODE (not decode) the original xml file you have.

    You can use the built-in flow service wm.record:recordToXMLValues rather than a java service. It uses XMLCoder under the hood (we tried to decode the file that was encoded using this flow service using the IDataXMLCoder and it didn’t work).

    Will


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


  • 3.  RE: XMLCoder

    Posted Thu December 05, 2002 10:08 PM

    Ken I think this is what you looking for this a section from one of my working java services in IS4.6 to read XML doc in XMLCoder. I think your problem is you need ObjectInputStream instead of FileStream.

    Values jms_config = null;
    Values val = null;

    XMLCoder coder = null;
    FileOutputStream ostream = null;
    ObjectOutputStream p = null;

    try
    {
    coder = new XMLCoder();
    FileInputStream istream = new FileInputStream(config_file);
    ObjectInputStream in_stream = new ObjectInputStream(istream);
    // Get current configuration
    jms_config = coder.decode(in_stream);

    Good luck


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


  • 4.  RE: XMLCoder

    Posted Mon March 17, 2003 09:17 AM

    Hello Ken,

    I had the same problem, but then I chose the IDataXMLCoder instead of XMLCoder and my problem was solved.

    Miriam


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


  • 5.  RE: XMLCoder

    Posted Mon July 05, 2004 03:25 PM

    Sanjay,

    you can use the pub.file:getFile service to read a file and it can be load as bytes or stream,choose what ever.Then map the output body/bytes to bytesToString service and nextstep will be stringToDocument flow.

    Note:The file should be placed in the webMethods home directory then only getFile service will work.

    HTH,


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