I create one xmlport at nav. And then i wann to run my xmlport and get data pass to my web. Can we get xml data from nav by using webservice? If it possible, kindly, pls guide tome.
Alternatively, you could expose a BigText as a VAR, take the incoming request, load that into a Xml Dom object, parse, perhaps do some processing logic and then kick off an xmlport to build xml, clear your bigtext variable and then return the resultant Xml as a string.
One more thing, i can not set data to BigText. Cos of length is over 1024.
Above part is solved ready. I replace with
bigtext.read(istream);
But i'm staying face with problem. ](*,)
I'm refer this link http://mibuso.com/forum/viewtopic.php?f=32&t=29557&hilit=MemoryStream&start=15. When i run .net application i got this error "{"Data at the root level is invalid. Line 1, position 1."}". So i checked the return variable at .net. I saw data length is 3. How come? But when i export to text/xml file from nav, i can get all data.
I'm using standard xmlport (item).
Here is my nav code
Name DataType Subtype Length
objOutStream OutStream
objInStream InStream
recTempBlob Record TempBlob
Item Record Item
Var Name DataType Subtype Length
Yes BigTextVar BigText
Item.SETRANGE("No.",'1000');
Item.FINDSET;
recTempBlob.INIT;
recTempBlob.Blob.CREATEOUTSTREAM(objOutStream);
xmlPort.SETTABLEVIEW(Item);
xmlPort.SETDESTINATION(objOutStream);
xmlPort.EXPORT;
recTempBlob.CALCFIELDS(Blob);
recTempBlob.Blob.CREATEINSTREAM(objInStream);
BigTextVar.READ(objInStream);
.Net Code
localhost.Web_Service_Function myInvoicesService = new WindowsApplication1.localhost.Web_Service_Function();
myInvoicesService.UseDefaultCredentials = true;
string _BigText = string.Empty;
myInvoicesService.FnXML(ref _BigText); //Return length is 3 (data is " þ<")
byte[] byteArray = new byte[_BigText.Length];
System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
byteArray = encoding.GetBytes(_BigText);
System.IO.MemoryStream memoryStream = new System.IO.MemoryStream(byteArray);
DataSet ds = new DataSet();
ds.ReadXml(memoryStream);
What wrong at my sample code? Kindly, guide to me.
Comments
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
Alternatively, you could expose a BigText as a VAR, take the incoming request, load that into a Xml Dom object, parse, perhaps do some processing logic and then kick off an xmlport to build xml, clear your bigtext variable and then return the resultant Xml as a string.
It'd look kinda like this:
Bill
Thanks for your reply. Please me try first. Later i will let you know result.
Best Regards,
Yukon
I follow your eg. But when i call function, i got this error. I create one codeunit and i call from nav (for testing).
Any idea for that?
Best Regards, :roll:
Yukon
Solved ready...
Regards,
Yukon
You right! I forget above case.
One more thing, i can not set data to BigText. Cos of length is over 1024.
Best Regards,
Yukon
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
bigtext.read(istream);
Thanks for your reply. Above part is solved ready. I replace with
But i'm staying face with problem. ](*,)
I'm refer this link http://mibuso.com/forum/viewtopic.php?f=32&t=29557&hilit=MemoryStream&start=15. When i run .net application i got this error "{"Data at the root level is invalid. Line 1, position 1."}". So i checked the return variable at .net. I saw data length is 3. How come? But when i export to text/xml file from nav, i can get all data.
I'm using standard xmlport (item).
Here is my nav code
.Net Code
What wrong at my sample code? Kindly, guide to me.
Best Regards,
Yukon
Try using UTF-8 as the xmlport format.
Yes! I'm using UTF-16. Now it is ok .... :thumbsup:
Best Regards,
Yukon