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.  TResponse Object nearly empty??

    Posted Thu June 17, 2004 03:58 PM

    Hi,

    If I make an interaktive query with the Tamino XQuery-Tool I get the following result:

    <?xml version="1.0"?>

    <xq:attribute doc_id=“d883”/>


    The query is:
    let
    $did:=input()/directory/host[@name=‘ahost2’]/host[@name=‘bhost2’]/host[@name=‘chost5’]/path[@name=‘apath2’]/path[@name=‘bpath2’]/path[@name=‘cpath3’]/path[@name=‘d883.xml’]/doc_info/@doc_id
    return $did

    but if I make the same query with a TXMLObjectAccessor the TResponse Object has only the following data (empty element)
    xq:attribute/
    but I need the doc_id…

    any suggestions??

    Thanx
    Markus


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


  • 2.  RE: TResponse Object nearly empty??

    Posted Thu June 17, 2004 09:23 PM

    Hello Markus,

    which object model are you using with the TXMLObjectAccessor - is it the TDOMObjectModel?
    Could you please post your code?

    Thanks,
    Trevor.


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


  • 3.  RE: TResponse Object nearly empty??

    Posted Mon June 21, 2004 02:26 PM

    Hello Trevor,

    yes, I’m using the TDOMObjectModel…

    here is the code:

    String xqueryString = “let $did:=input()/directory/host[@name=‘ahost2’]/host[@name=‘bhost2’]/host[@name=‘chost5’]/path[@name=‘apath2’]/path[@name=‘bpath2’]/path[@name=‘cpath3’]/path[@name=‘d883.xml’]/doc_info/@doc_id return $did”;

    TXMLObjectAccessor xmlObjectAccessor = connection.newXMLObjectAccessor(
    TAccessLocation.newInstance( “ino:etc” ),
    TDOMObjectModel.getInstance() );

    TXQuery xquery = TXQuery.newInstance( xqueryString );
    System.out.println("T-XQuery: " + xquery.toString());

    try {
    TResponse response = xmlObjectAccessor.xquery( xquery);

    TXMLObjectIterator iterator = response.getXMLObjectIterator();
    System.out.print( “The query "” + xqueryString + "" returns " );
    if (!iterator.hasNext()) {
    System.out.println( “no data!” );
    } else {
    while (iterator.hasNext()) {
    TXMLObject xmlObject = iterator.next();
    System.out.print( " count: " +iterator.getCount() );
    }
    }
    String xqueryResult = xmlObjectAccessor.xquery( xquery ).getQueryContentAsString() ;
    System.out.println("T-XQuery Result: " + xqueryResult);
    return xqueryResult;
    } catch (TXQueryException tqe) {
    System.out.println( "T-XQuery FEHLER: " + tqe.toString() );
    }
    catch (TException te) {
    System.out.println( "T-XQuery FEHLER: " + te.toString() );
    }


    I hope this helps :slight_smile:

    Markus


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


  • 4.  RE: TResponse Object nearly empty??

    Posted Tue June 29, 2004 08:06 AM

    Hi Markus,

    it looks like the “getQueryContentAsString()” method is not doing what you and I would expect here. You should open a request with your local Customer Support Center about this.

    In the meantime, you could use the “writeTo” method of the TXMLObject class to output the desired result:

       if (!iterator.hasNext()) {
    System.out.println( "no data!" );
    } else {
    while (iterator.hasNext()) {
    TXMLObject xmlObject = iterator.next();
    
    // TFO added these two lines ////////////
    System.out.println("\n\nresult: ");    //
    xmlObject.writeTo(System.out);         //
    /////////////////////////////////////////
    
    System.out.print( "\n\n count: " + iterator.getCount() );
    }
    }


    Cheers,
    Trevor.


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


  • 5.  RE: TResponse Object nearly empty??

    Posted Tue June 29, 2004 11:52 AM

    Hi Trevor,

    thank you for your answer :wink:

    I tried your workaround with the ‘writeTo’-method…
    …and now it works :wink:

    but: what for is the .getQueryContenAsString() method ??? I’ll request my support… :wink:

    Thanx
    Markus


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