I am writing a codeunit which is published as a SOAP service. I am getting below error in my .net console app. I am using BC cloud sandbox
Microsoft.Dynamics.Nav.Runtime.NavInStream variable not initialized.
Here is my code unit
codeunit 50131 SalesOrderCodeUnit
{
trigger OnRun()
begin
end;
procedure Create(Base64Text: text)
var
base64Convert: codeunit "Base64 Convert";
doc: XmlDocument;
vConvertedContent: text;
varTempBlob: Codeunit "Temp Blob";
varInStream: InStream;
varOutStream: OutStream;
xmlNodeListParent: XmlNodeList;
element1: XmlElement;
salesOrderXML: Text;
xmlParentNode: XmlNode;
xmlChildNode: XmlNode;
i: integer;
// sales header
SalesHeader: Record "Sales Header";
Document_Type: Enum "Sales Document Type";
Sell_to_Customer_No: Code[20];
Sell_to_Customer_Name: Text[100];
begin
salesOrderXML := base64Convert.FromBase64(Base64Text);
varInStream.Read(salesOrderXML);
varTempBlob.CreateInStream(varInStream, TextEncoding::WINDOWS);
doc := XmlDocument.Create(varInStream);
doc.SelectNodes('//SalesOrders', xmlNodeListParent);
for i := 1 to xmlNodeListParent.Count do begin
if xmlNodeListParent.Get(i, xmlParentNode) then begin
SalesHeader.Init();
xmlParentNode.SelectSingleNode('//Sell_to_Customer_No', xmlChildNode);
Sell_to_Customer_No := xmlChildNode.AsXmlElement().InnerText;
xmlParentNode.SelectSingleNode('//Sell_to_Customer_Name', xmlChildNode);
Sell_to_Customer_Name := xmlChildNode.AsXmlElement().InnerText;
SalesHeader.Validate("Document Type", SalesHeader."Document Type"::Order);
SalesHeader.Validate("Sell-to Customer No.", Sell_to_Customer_No);
SalesHeader.Validate("Sell-to Customer Name", Sell_to_Customer_Name);
SalesHeader.Insert(true);
end;
end;
end;
}