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.  Update problem with ino:docname

    Posted Tue November 05, 2002 08:34 AM

    Hi all,

    I really don’t know if I’m that foolish or not as I’ve encountered so much problem with the Tamino API for Java. Having not less experience in Java, I supposed it is a few trivial call to the APIs, but I can’t make it work.
    Can anyone point me out why the below code doesn’t work? When I can see Transaction committed successfully printed out, the records are really updated. But…
    My records’ docname originally have the format, for example “xyz:1234”, I just want to change it to “document:1234”, but the ino:docname is missing after
    the transaction committed!! Why? (Please assume all variables are declared correctly as it is only a snapshot)

    --------------------------------------------------------------------------------
    try {
    myTransaction = connectionA.useLocalTransactionMode();
    TQuery tQuery = TQuery.newInstance(“/article”);
    TResponse response = accessorA.query( tQuery, 10 );
    if( response.hasFirstXMLObject() ) {
    TXMLObjectIterator itr = response.getXMLObjectIterator();
    for ( int count = 0; itr.hasNext() && count < 10 ; count++) {
    TXMLObject xmlObject = itr.next();
    Element element = (Element)xmlObject.getElement();

    String docname = “document” + count;
    xmlObject.setId(xmlObject.getId());
    xmlObject.setDocname( docname );
    response = accessorA.update( xmlObject );
    }
    }
    myTransaction.commit();
    connectionA.useAutoCommitMode();
    System.out.println("Transaction committed successfully … “);
    } catch (TException te) {
    te.printStackTrace();
    myTransaction.rollback();
    System.out.println(te.toString()+” - transaction rollback … ");
    } finally {
    // Close both connections
    connectionA.close();
    connectionB.close();
    System.out.println("Connection closed successfully … ");
    }
    ----------------------------------------------------------------------------------

    Best regards,
    Lun


    #webMethods
    #API-Management
    #webMethods-Tamino-XML-Server-APIs


  • 2.  RE: Update problem with ino:docname

    Posted Tue November 05, 2002 10:46 AM

    The API documentation says that once a document has been stored with a docname, that name cannot be updated (see method setDocName() in TXMLObject).

    Also, if a document has both ino:id and a document name, the ino:id “takes precedence”. Any supplied docname is ignored on the update, and any existing docname is deleted (see method update() in TXMLObjectAccessor).

    So to achieve a change of docname you need code like this:

    Element element = (Element)xmlObject.getElement();
    response = xmlObjectAccessor.delete(xmlObject);
    element.removeAttribute("ino:id");
    String docname = "Newname";
    xmlObject.setDocname( docname );
    response = xmlObjectAccessor.insert( xmlObject );



    This deletes your existing object, then removes the ino:id attribute from the original document’s xml, and inserts a new document with the same xml content but a new docname.

    HTH


    #webMethods
    #webMethods-Tamino-XML-Server-APIs
    #API-Management


  • 3.  RE: Update problem with ino:docname

    Posted Tue November 05, 2002 11:07 AM

    Thanks again Bill (I believe it’s you again point out my fault)

    I’m really too foolish to just blindly try and try and try to debug, without just step back a little to digest the detail documentation of TXMLObject.setDocName() and TXMLObjectAccessor.update().

    My apologies and many thanks!!

    Best regards,
    Lun


    #webMethods-Tamino-XML-Server-APIs
    #webMethods
    #API-Management