Outstream initialize error

kenjes
Member Posts: 76
Hi
I have the following code - and gets the error :
"Microsoft.Dynamics.Nav.Runtime.NavOutStream variable not initialized"
Can anyone help med here - Thanks
I have the following code - and gets the error :
"Microsoft.Dynamics.Nav.Runtime.NavOutStream variable not initialized"
LOCAL SendXMLCall(WebServiceURL : Text;Request : InStream;VAR Response : OutStream;VAR ErrorMsg : Text) StatusOK : Boolean //Prepare the request. Load it as a text into an XML document. vBigText.READ(Request); vBigText.GETSUBTEXT(TempString,1); XMLDoc := XMLDoc.XmlDocument(); XMLDoc.LoadXml(TempString); //Start the web service call XMLHttpRequest := XMLHttpRequest.Create(WebServiceURL); XMLHttpRequest.Method('POST'); XMLHttpRequest.ContentType('text/xml;charset=utf-8'); XMLHttpRequest.KeepAlive(TRUE); //Send the XMLDoc to the HttpRequest streamWritter := streamWritter.StreamWriter(XMLHttpRequest.GetRequestStream, Encoding.UTF8); XMLDoc.Save(streamWritter); streamWritter.Close(); //Get the http response and save it in the response variable XMLHttpResponse := XMLHttpRequest.GetResponse; XMLDoc.Load(XMLHttpResponse.GetResponseStream); XMLHttpResponse.Close; XMLDoc.Save(Response);
Can anyone help med here - Thanks
0
Best Answer
-
The code is OK. Before you call the function, you have to link the variables "Request" and "Response" to a source.
For example:
TempBlob.Blob.CREATEINSTREAM(Request);
TempBlob.Blob.CREATEOUTSTREAM(Response);My blog - https://www.HannesHolst.com/5
Answers
-
The code is OK. Before you call the function, you have to link the variables "Request" and "Response" to a source.
For example:
TempBlob.Blob.CREATEINSTREAM(Request);
TempBlob.Blob.CREATEOUTSTREAM(Response);My blog - https://www.HannesHolst.com/5 -
Hi
Yes, i figured it out
Can you tell me how to start handling the Response (OutStream). Like Read it as an XML file, and get some value out
Thanks
0 -
Hi kenjes,
Here is code snippet from me.
It reads a stream and puts it in a Text-variable (which is may not the best way).
The Text-variable will be loaded in the XML-Handler of dotNet.
The goal is to show the text of "faultstring", if it exists in the XML.ResponseBlob.Blob.CREATEINSTREAM(ResponseStream); ResponseStream.READ(ResponseContainer); ResponseXML := ResponseXML.XmlDocument; ResponseXML.LoadXml(ResponseContainer); XMLDocNodeList := ResponseXML.GetElementsByTagName('faultstring'); XMLDocNode := XMLDocNodeList.Item(0); IF XMLDocNodeList.Count > 0 THEN BEGIN ERROR(XMLDocNode.InnerText); END;
Name DataType Subtype ResponseXML DotNet System.Xml.XmlDocument.'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' ResponseBlob Record TempBlob ResponseStream InStream XMLDocNodeList DotNet System.Xml.XmlNodeList.'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' XMLDocNode DotNet System.Xml.XmlNode.'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' ResponseContainer Text
My blog - https://www.HannesHolst.com/0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions