webMethods

webMethods

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

Cursor TStreamAccessor ...

  • 1.  Cursor TStreamAccessor ...

    Posted Sun August 26, 2007 04:51 PM

    Hello,

    can you please give me an example of how to use the cursoring function when i use the response as stream??

    Iam a little confused, because iam trying to get the response as TInputStream with the TStreamAccessor. That works fine…but now i have the problem of big results and i want to cursor trough the result. Get the first 100 than the next 100 results…and so on. Then i write the first to a file, till i received the complete result.

    Can you please help me. I already found somebody asking for this problem…and the answer was use the fetchCursor()-Method, but sorry…cant you give us a example code or sth like this??

    Thank you very much!

    My code looks like this:

    		TXQuery xqueryBuffer = TXQuery.newInstance(sbQuery.toString());
    
    // Invoke the query operation
    TInputStream response = streamAccessor.xquery(xqueryBuffer);
    //TInputStream response = streamAccessor.openCursor(xqueryBuffer, 1, 4000);
    
    long lDuration = System.currentTimeMillis() - lStartDuration;
    logger.info("XQuery duration:  " + lDuration + " ms");
    
    try {
    
    //TInputStream test = streamAccessor.fetchCursor("response", 1, 100);
    BufferedReader in = new BufferedReader(new InputStreamReader(
    response,"UTF8"));
    String str = "";
    while (in.ready()) {
    str = in.readLine();
    stringWriter.append(str);
    }
    } catch (IOException e) {
    }
    

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