I have a codeunit where I am recieving TempBlob containing an xml. I am handling and processing the xml, and end up with a new xml that I want to return. But for some reason the stream is empty when returning ](*,)
Snippets from the code
//Create XML
CLEAR(TempBlob);
TempBlob.Blob.CREATEOUTSTREAM(Outstr);
XMLport.SETDESTINATION(Outstr);
XMLport.EXPORT;
Works fine, my Outstr has the resulting xml document
// Process Document
ProcessDocument(TempBlob);
//What are we recieving
CREATE(lXmlDoc);
TempBlob.Blob.CREATEINSTREAM(Instr);
lXmlDoc.async := FALSE;
lXmlDoc.load(Instr);
lXmlDoc.save('C:\temp\xmlport.xml');
ProcessDocument takes the TempBlob record as a Var
The function extracts the document from TempBlob processes it and ends up with a xmldoc ('Microsoft XML, v6.0'.DOMDocument)
But when trying to put the XMLDoc back into the TembBlob stream it goes blank for some reason
XmlDoc.load(XmlHttp.responseXML);
ProcessDoc.Blob.CREATEOUTSTREAM(Outstr);
//XmlDoc.save('C:\temp\xmlport.xml');
XmlDoc.save(Outstr);
If I use the XMLDoc.Save the file is there, but when I'm back to where I called the function, the stream is empty, or at least I can't load anything from it
Does anybody have some suggestions as to what I am missing?
N.B. Yes I know that I can just save the xml and then load it when I return from the function, but the whole idea is to work within the streams and not having to have disc access.
Comments
One of the things perhaps I would check is the state of Temp.Blob variable prior to assign it XML doc.
e.g.
if tempblob.Blob.HASVALUE then begin
//Now Create Instream
tempblob.Blob.CREATEINSTREAM(InsStr);
//Assign it to XML doc
lXmlDoc.async := FALSE;
lXmlDoc.load(Instr);
end else begin
//Create a quick XML message that contain Node for return
end;
If Temp.Blob is Null I would then investigate ProcessDocument function.
Hope this help.
The main parameter is to send request with POST option (it means that system should wait for response, in other words, system will work in synchronous way), the second option is to say to XmlHttp object, that request should be in xml\html.
You could try to go on with my example:
Follow my blog at http://x-dynamics.blogspot.com
Loving/Hating Navision since 2006