When I try to execute the QueryItemIterator sample which is provided in the QuerySamples of Tamino XML Server’s .NET API, I get an exception because of the ItemIterator.
The system throws an exception while executing the next() method of the ItemIterator.
The code is:
using System;
using System.Xml;
using System.Diagnostics;
using System.Collections;
using SoftwareAG.Tamino.Api;
namespace SoftwareAG.Tamino.QuerySamples
{
///
/// Demonstrates how to use the TaminoItemIterator class of the Tamino API to
/// iterate through a query result set. Each individual item in the list is accessed
/// as an XmlNode.
///
///
///
/// Usage: QueryItemIterator ‘Tamino URL’ ‘Collection’ ‘XQuery’ ‘PageSize’
///
/// Example: QueryItemIterator http://myserver/tamino/mydb APISimpleSamples input()/Property[@Category=‘Sell’] 5
///
///
/// If a nonzero pagesize is specified, the Tamino cursor is used. A Tamino cursor
/// cannot be used in mode TaminoConnectionMode.AutoCommit, therefore this example opens the
/// connection in mode TaminoConnectionMode.LocalTransaction.
///
///
public class QueryItemIterator
{
///
/// The main entry point for the application.
///
[STAThread]
static void Main(string args)
{
// process args
if ( args.Length != 4 )
{
Console.WriteLine(“Usage: QueryItemIterator ‘Tamino URL’ ‘Collection’ ‘XQuery’ ‘PageSize’”);
Console.WriteLine(“Example: QueryItemIterator http://myserver/tamino/mydb APISimpleSamples input()/Property[@Category=‘Sell’] 5”);
return;
}
string dbUrl = args[0];
string collection = args[1];
string xquery = args[2];
int pageSize = int.Parse(args[3]);
Console.WriteLine("Tamino URL = “+dbUrl+”, Collection = "+collection+
", XQuery = “+xquery+”, PageSize = “+pageSize);
// create connection
TaminoConnection connection = new TaminoConnection(dbUrl);
// open connection
connection.Open(TaminoConnectionMode.LocalTransaction);
// begin transaction
TaminoTransaction tx = connection.BeginTransaction();
// create command for collection
TaminoCommand command = connection.CreateCommand(collection);
// do query
TaminoQuery query = new TaminoQuery(xquery);
TaminoQueryResponse qr = command.Query(query, pageSize);
Trace.Assert(qr.ReturnValue.Equals(“0”), qr.ErrorText);
TaminoItemIterator itemIt = qr.GetItemIterator();
while(itemIt.Next())
{
XmlNode node = itemIt.GetNode();
Console.WriteLine(“Item[”+itemIt.AbsoluteIndex+”]: "+node.OuterXml);
}
// close the query result set
qr.Close();
// close connection - this will commit the local transaction implicitly
connection.Close();
}
}
}
Stack Trace is like below:
C:\TAMINO\TAMINO~1\SAMPLES\QUERYS~1\QUERYI~1\BIN\DEBUG>QueryItemIterator http://
ServerName/tamino/Test TestCollection input()/Property[@Category=‘Sell’] 5
Tamino URL = http://ServerName/tamino/Test, Collection = TestCollection, XQuery = in
put()/Property[@Category=‘Sell’], PageSize = 5
Unhandled Exception: System.NullReferenceException: Object reference not set to
an instance of an object.
at SoftwareAG.Tamino.Api.Response.ResponseHandler2.GetCursor()
at SoftwareAG.Tamino.Api.TaminoPageIterator.ReadPage(Boolean next)
at SoftwareAG.Tamino.Api.TaminoPageIterator.Next()
at SoftwareAG.Tamino.Api.TaminoItemIterator.Next()
at SoftwareAG.Tamino.QuerySamples.QueryItemIterator.Main(String args) in c:
\tamino\taminoapi4dotnet\samples\querysamples\queryitemiterator\queryitemiterato
r.cs:line 71
I also wrote a similar code in an ASP.NET page with C#, and it throws the same exception. I am running Tamino XML Server 4.1.1.1 on a Windows 2000 Server and trying to execute the code on a windows 2000 pro machine where .NET Framework version 1.0 is installed…
I will be glad if someone can help me,
Thank you…