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
Expand all | Collapse all

accessor.update (objInstance)

  • 1.  accessor.update (objInstance)

    Posted Fri November 15, 2002 10:30 PM

    i have the following xml in AccessList collection in Tamino

    <?xml version="1.0" encoding="UTF-8"?>




    sip:spdsafm@tfdt.op



    my fragment of code is

    if (ti.hasNext ())
    {

    TXMLObject objInstance = ti.next() ; Element elemInstance = (Element)objInstance.getElement () ;

    Document doc = elemInstance.getOwnerDocument() ;
    Element elemTitle = doc.createElement (“watcher”) ;
    Text textTitle = doc.createTextNode (“sip:io@tggin.com”) ;

    elemTitle.appendChild (textTitle) ;
    elemInstance.appendChild (elemTitle) ;

    accessor.update (objInstance) ;
    }



    where ti is an iterator of Tresponse of the query /AccessList/instance

    So the line Element elemInstance = (Element)objInstance.getElement () ; should take the element watcher
    but it doesn’t work, infact accessor.update (objInstance) ; gives me the ERROR:

    /AccessList/instance
    com.softwareag.tamino.db.API.accessor.TUpdateException
    Access Failure:
    ReturnValue:8814
    Code:INOXRE8814
    MessageText:Element/attribute name not found
    MessageLine:Line 1, Column 1: Element name = instance
    at com.softwareag.tamino.db.API.accessor.TAccessFailureVerifier.verifyUpdateResponse(TAccessFailureVerifier.java:49)
    at com.softwareag.tamino.db.API.accessor.TXMLObjectAccessorImpl.update(TXMLObjectAccessorImpl.java:150)
    at Database.show(Database.java:110)
    at Database.main(Database.java:227)
    Exception in thread “main”

    Any idea?
    Brgs
    @nto


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


  • 2.  RE: accessor.update (objInstance)

    Posted Sat November 16, 2002 12:15 PM

    INOXRE8814

    Element/attribute name not found

    Explanation
    The specified element or attribute is unknown in the Data Map.

    Action
    Correct the element or attribute name and repeat the request.

    If i write the content of objInstance with

    objInstance.writeTo(System.out);

    I obtain the correct updated document:


    sip:spam@tiscali.it
    sip:io@tin.itcom.softwareag.tamino.db.API.accessor.TInsertException
    Access Failure:
    ReturnValue:8814
    Code:INOXRE8814
    MessageText:Element/attribute name not found
    MessageLine:Line 1, Column 1: Element name = instance
    at com.softwareag.tamino.db.API.accessor.TAccessFailureVerifier.verifyInsertResponse(TAccessFailureVerifier.java:40)
    at com.softwareag.tamino.db.API.accessor.TXMLObjectAccessorImpl.insert(TXMLObjectAccessorImpl.java:93)
    at Database.show(Database.java:115)
    at Database.main(Database.java:232)
    Exception in thread “main”

    I don’t understand “Element/attribute name not found”… the update is correct…
    I have no reason to believe that accessor.update (objInstance) fails.

    ThX
    @nto


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


  • 3.  RE: accessor.update (objInstance)

    Posted Sat November 16, 2002 12:18 PM

    I’m sorry but in the second update i have changed
    the watcher element:

    Assume:
    sip:io@tggin.com=sip:io@tin.it

    @nto


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


  • 4.  RE: accessor.update (objInstance)

    Posted Mon November 18, 2002 09:27 AM

    I think your problem is that you are trying to update the Element “instance” directly, without reference to its parent document “AccessList”.

    Tamino currently handles document-level updates natively. If you want to update a Node directly, you need to use NodeLevelUpdate (see FAQ).

    Alternatively you can change your program to retrieve the parent “AccessList” document, add the required node and update the entire document.

    HTH


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


  • 5.  RE: accessor.update (objInstance)

    Posted Mon November 18, 2002 10:21 AM



    You can use NodelLevelUpdate if you use Microsoft Internet Information Server (IIS) as your web gateway to Tamino. You can not use NodeLevelUpdate with Apache.



    Cause on Murphy’s law i’m using Apache, so i cannot use NodeLevelUpdate functionality…

    HLP PLZ!!!
    @nto


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


  • 6.  RE: accessor.update (objInstance)

    Posted Mon November 18, 2002 11:38 AM

    If you are using the Tamino API for Java you cannot use the NodeLevelUpdate functionality anyway. Your program logic is essentially correct but as Bill has pointed out the reason for the error is that you are updating at the wrong element level. So you would have to change the query to retrieve complete documents rather than elements.


    Stuart Fyffe-Collins
    Software AG (UK) Ltd.


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


  • 7.  RE: accessor.update (objInstance)

    Posted Mon November 18, 2002 12:08 PM

    I’m trying to query /AccessList (i.e the root element) and then i’ll use getChildren(“children name”), is a correct approach?

    BrgS
    @nto


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


  • 8.  RE: accessor.update (objInstance)

    Posted Mon November 18, 2002 01:47 PM

    org.w3c.dom.Node has a method getChildNodes() that returns a NodeList, and org.w3c.dom.Element has a method getElementsByTagName(String) that also returns a NodeList.

    If the only children of “AccessList” are “instance” nodes, I think the two methods should return the same NodeList.

    The safer option is probably getElementsByTagName(“instance”).

    Comments anyone?

    HTH


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


  • 9.  RE: accessor.update (objInstance)

    Posted Mon November 18, 2002 05:43 PM

    I try to do: (with correct query=/AccessList)

    TXMLObject xmlObject = response.getFirstXMLObject();
    Document doc = (Document) xmlObject.getDocument();
    myTransaction = connection.useLocalTransactionMode();

    xmlObject.getElement();

    NodeList List = doc.getElementsByTagName(“instance”);
    but it doesn’t work.
    I see in the example InsertConstraintCheck it seems that getElementByTagName is a method of the class Document, not Element.
    What about my way to proceed?
    BrG @nto


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


  • 10.  RE: accessor.update (objInstance)

    Posted Mon November 18, 2002 05:45 PM

    Forget in the previous post the line:
    xmlObject.getElement();

    there isn’t in my file.
    Sorry.
    @nto


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


  • 11.  RE: accessor.update (objInstance)

    Posted Mon November 18, 2002 06:16 PM

    The method getElementsByTagName() belongs to both Document and Element so you can take your pick.

    What do you mean when you say it doesn’t work? Does it throw an exception or just return an empty NodeList?

    Can you please post your schema, the xml instance you are processing and your complete code (preferably as an attachment)?


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


  • 12.  RE: accessor.update (objInstance)

    Posted Tue November 19, 2002 10:39 AM

    i think it’s an import problem.

    C:\JAVA\Database2.java:82: cannot resolve symbol
    symbol : variable myTransaction
    location: class Database2
    myTransaction = connection.useLocalTransactionMode();
    ^
    C:\JAVA\Database2.java:86: cannot resolve symbol
    symbol : class NodeList
    location: class Database2
    NodeList List = doc.getElementsByTagName(“instance”);
    ^
    C:\JAVA\Database2.java:86: cannot resolve symbol
    symbol : method getElementsByTagName (java.lang.String)
    location: class org.jdom.Document
    NodeList List = doc.getElementsByTagName(“instance”);

    My import are:
    import com.softwareag.tamino.db.API.accessor.;
    import com.softwareag.tamino.db.API.common.
    ;
    import com.softwareag.tamino.db.API.connection.;
    import com.softwareag.tamino.db.API.objectModel.
    ;
    //import com.softwareag.tamino.db.API.objectModel.jdom.;
    import com.softwareag.tamino.db.API.objectModel.dom.
    ;
    import com.softwareag.tamino.db.API.response.;
    import org.jdom.
    ;
    import org.jdom.input.;
    import org.jdom.output.
    ;
    import java.io.;
    import java.util.
    ;
    //import org.w3c.dom.* ;

    import org.jdom.input.SAXBuilder;
    import org.jdom.output.XMLOutputter;


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


  • 13.  RE: accessor.update (objInstance)

    Posted Tue November 19, 2002 10:46 AM

    I resolve the first problem with:
    TLocalTransaction myTransaction = null;
    but the others errors remain.

    @nto


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


  • 14.  RE: accessor.update (objInstance)

    Posted Tue November 19, 2002 11:06 AM

    My fault - I assumed you were using DOM but you’re using JDOM - I should have asked - sorry.

    I haven’t used JDOM but from the API documentation I think you need to use getChildren(“instance”), as you suggested, and this will return a java.util.List of Elements.

    HTH


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


  • 15.  RE: accessor.update (objInstance)

    Posted Tue November 19, 2002 11:27 AM

    Many thanks for the patience.
    I’m a little bit confused about DOM and JDOM and i make confusion with their methods.
    Where i can find a good resource for a good explanation about these methods?
    BrG
    @nto


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


  • 16.  RE: accessor.update (objInstance)

    Posted Tue November 19, 2002 12:17 PM

    You can find online documentation for JDOM here and for DOM(2) here and you will probably want to download your own copy from these sites too.

    HTH


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