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.


#TechXchangePresenter
 View Only
  • 1.  getTotalCount once again!

    Posted Thu October 10, 2002 02:00 PM

    Hello!

    I have not solved yet my problem to get record count to mydb tamino. I tried in this way:

    ---------------------------------------
    import java.util.;
    import org.w3c.dom.
    ;
    import com.softwareag.tamino.API.dom.*;

    public class count {
    public static final void main(String arg) throws Exception {
    TaminoClient tc = new TaminoClient(“http://localhost/tamino/mydb/col”);
    tc.setPageSize(0);
    tc.startSession();
    try {
    TaminoResult tr = tamino.query(“count(/doc[id_client=‘12345’])”);
    Element el = tr.getElement();
    System.out.println(“GET_TAG_NAME=” +el.getTagName());
    System.out.println(“TO_STRING=” +el.toString());
    System.out.println(“PRINT_TREE=”);
    tc.printTree(el);
    tc.endSession();
    }
    catch (com.softwareag.tamino.API.dom.TaminoError Error)
    {
    System.err.println(
    "Tamino Error Code: " + Error.responseCode + “\n” +
    "Tamino Error Text: " + Error.errorText);
    }
    }
    }
    ---------------------------------------
    The following output text I got:

    GET_TAG_NAME=xql:result
    TO_STRING=xql:result9</xql:result>
    PRINT_TREE=
    –xql:result
    ?–#text 9
    ---------------------------------------

    How can I get the text ONLY value 9?

    Please help me!

    Any help will be very appreciated!

    Thanks in advance!

    best regards,
    Dariusz Baumann


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


  • 2.  RE: getTotalCount once again!

    Posted Thu October 10, 2002 02:46 PM

    I tried in this way:
    ------------------------------------------------
    import java.util.;
    import org.w3c.dom.
    ;
    import com.softwareag.tamino.API.dom.*;

    public class count {
    public static final void main(String arg) throws Exception {
    TaminoClient tamino = new TaminoClient(“http://localhost/tamino/mydb/col”);
    tamino.setPageSize(0);
    tamino.startSession();
    try {
    TaminoResult tr = tamino.query(“count(/doc[id_client=‘12345’])”);
    Element el = tr.getElement();
    System.out.println(“GET_NODE_NAME=” +el.getNodeName());
    System.out.println(“GET_NODE_VALUE=” +el.getNodeValue());
    tamino.endSession();
    }
    catch (com.softwareag.tamino.API.dom.TaminoError Error)
    {
    System.err.println(
    "Tamino Error Code: " + Error.responseCode + “\n” +
    "Tamino Error Text: " + Error.errorText);
    }
    }
    }
    ------------------------------------------------
    … but unfortunately, I got the following text message:

    GET_NODE_NAME=xql:result
    GET_NODE_VALUE=null

    Please help me! Thanks a lot!

    best regards,
    Dariusz Baumann


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


  • 3.  RE: getTotalCount once again!

    Posted Thu October 10, 2002 02:55 PM

    The last my try was:
    -----------------------------------------------
    public class count {
    public static final void main(String arg) throws Exception {
    // TaminoClient tc = new TaminoClient(“http://localhost/tamino/mydb/col”);
    tc.setPageSize(0);
    tc.startSession();
    try {
    // TaminoResult tr = tc.query(“count(/doc[id_client=‘12345’])”);
    Element el = tr.getElement();
    System.out.println(“GET_NODE_NAME=” +el.getNodeName());
    System.out.println(“GET_NODE_VALUE=” +el.getElementsByTagName(“xql:result”).item(0).getNodeValue());
    tc.endSession();
    }
    catch (com.softwareag.tamino.API.dom.TaminoError Error)
    {
    System.err.println(
    "Tamino Error Code: " + Error.responseCode + “\n” +
    "Tamino Error Text: " + Error.errorText);
    }
    }
    }
    -----------------------------------------------
    … but I got the following text:

    GET_NODE_NAME=xql:result
    Exception in thread “main” java.lang.NullPointerException at count.main(count.java:16)

    Please help me! Thanks!

    best regards,
    Dariusz Baumann


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


  • 4.  RE: getTotalCount once again!

    Posted Thu October 10, 2002 03:34 PM

    el is a Text object. you need to type cast it and call its getData method.

    System.out.println(“GET_TAG_NAME=” +el.getTagName());
    System.out.println(“GETDATA=” +((Text)el).getData());
    christian


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


  • 5.  RE: getTotalCount once again!

    Posted Thu October 10, 2002 03:53 PM

    I tried like you wrote but it doesn’t work! My code is:

    --------------------------------------------------
    import java.util.;
    import org.w3c.dom.
    ;
    import com.softwareag.tamino.API.dom.*;

    public class count {
    public static final void main(String arg) throws Exception {
    TaminoClient tc = new TaminoClient(“http://localhost/tamino/mydb/col”);
    tc.setPageSize(0);
    tc.startSession();
    try {
    TaminoResult tr = tc.query(“count(/doc[id_client=‘12345’])”);
    Element el = tr.getElement();
    System.out.println(“GET_TAG_NAME=” +el.getTagName());
    System.out.println(“GETDATA=” +((Text)el).getData());
    tc.endSession();
    }
    catch (com.softwareag.tamino.API.dom.TaminoError Error)
    {
    System.err.println(
    "Tamino Error Code: " + Error.responseCode + “\n” +
    "Tamino Error Text: " + Error.errorText);
    }
    }
    }
    --------------------------------------------------

    I got the following text:

    GET_TAG_NAME=xql:result
    Exception in thread “main” java.lang.ClassCastException: com.docuverse.dom.BasicElement at count.main (count.java:16)

    Please help me! Thanks!

    best regards,
    Dariusz Baumann


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


  • 6.  RE: getTotalCount once again!

    Posted Thu October 10, 2002 06:32 PM

    Hi Dariusz,

    the problem is that the value is stored within a child node:

        public static final void main(String arg[]) throws Exception {
    TaminoClient tc = new TaminoClient("http://localhost/tamino/mydb/col");
    tc.setPageSize(0);
    tc.startSession();
    try {
    TaminoResult tr = tc.query("count(/doc[id_client='12345'])");
    Element el = tr.getElement();
    
    System.out.println("GET_TAG_NAME=" + el.getTagName());
    
    Node elChild = el.getFirstChild();
    System.out.println("GET_TAG_NAME=" + elChild.getNodeName());
    System.out.println("GETDATA=" + elChild.getNodeValue());
    
    tc.endSession();
    
    } catch (com.softwareag.tamino.api.dom.TaminoError Error) {
    System.err.println("Tamino Error Code: " + Error.responseCode + "\n" +
    "Tamino Error Text: " + Error.errorText);
    }
    }



    Cheers,
    Trevor.


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


  • 7.  RE: getTotalCount once again!

    Posted Fri October 11, 2002 12:15 PM

    Thanks a lot, Trevor Ford !
    Now it works! :):slight_smile:

    best regards,
    Dariusz Baumann


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