Tamino 4.1.4.1.
Tried a method to Insert/Retrieve NON XML in/from ino:etc (see below). File is a 90KB “jpg”.
Operation typically works when executed once, but when trying the method for several times (e.g. in a loop) it fails with different types of exceptions:
System.IO.IOException or
System.Net.WebException (see attachment).
There are some more questions concerning NON XML:
Is there a preferred method for reading from TaminoDocument.NonXmlDocument? When working with Tamino 4.1.1.1 I got an exception when trying to read using Stream.ReadByte(); Stream.Read() worked. Did not try this with 4.1.4.
After a retrieve operation, how long can I read from the TaminoDocument.NonXmlDocument? When working with transactions I got an exception when trying to read after the transaction commit operation.
Is it necessary to close the TaminoDocument.NonXmlDocument stream after finished with reading?
public static void TaminoNonXMLBase(String fn, String toFn)
{
TaminoConnection connection = new TaminoConnection(TaminoDb);
connection.Open(TaminoConnectionMode.AutoCommit);
TaminoCommand command = connection.CreateCommand(“ino:etc”);
FileStream stream = new FileStream(fn, FileMode.Open);
TaminoDocument doc = new TaminoDocument(stream, “image/jpg”);
doc.DocName = Path.GetFileName(fn);
doc.DocType = “ino:nonXML”;
TaminoResponse response = command.Insert(doc);
stream.Close();
if (response.ReturnValue == “0”)
{
String id = “ino:nonXML” + “/” + Path.GetFileName(fn);
doc = command.Retrieve(new TaminoUri(id));
Stream istream = doc.NonXmlDocument;
FileStream oStream = new FileStream(toFn, FileMode.OpenOrCreate);
byte bytes = new byte[1000];
int numBytesRead = 0, cur;
while ((cur = istream.Read(bytes, 0, 1000)) > 0)
{
oStream.Write(bytes, 0, cur);
numBytesRead += cur;
}
oStream.Close();
istream.Close();
}
connection.Close();
}
ex.txt (1.39 KB)
#webMethods-Tamino-XML-Server-APIs#webMethods#API-Management