Problem with BigText and OCX "Microsoft Internet Transfer Control 6.0"

kola1
Member Posts: 6
Hello!
We are trying to retrieve some information from a webservice in our Navision 5 system. Therefore, we use the OCX "Microsoft Internet Transfer Control 6.0" and do a GET request from a URL.
As an answer, we receive a string of text. This text can be bigger then 1024 digits - so we can not work with a normal text variable when assigning the return value like this:
Result:= MIT.OpenURL(ServiceURL);
Due to that, we want to use the type BigText, which should be big enough. The problem is, that it doesnt work - the text is not assigned. When we assign it like this:
Result.ADDTEXT(MIT.OpenURL(ServiceURL));
and afterwards check the length of the variable, it is always 0.
MESSAGE(FORMAT(Result.LENGTH));
Is there any difference regarding what values can be assigned? Or do you think of any other possiblity? I already tried writing the result directly into a text file - this can also only be 1024 digits at a time. I also wasn't able to do it with a blob field..
If you know what I did wrong, or have any idea how to handle it otherwise, I would be happy for any help.
Thanks for any input,
kola1
We are trying to retrieve some information from a webservice in our Navision 5 system. Therefore, we use the OCX "Microsoft Internet Transfer Control 6.0" and do a GET request from a URL.
As an answer, we receive a string of text. This text can be bigger then 1024 digits - so we can not work with a normal text variable when assigning the return value like this:
Result:= MIT.OpenURL(ServiceURL);
Due to that, we want to use the type BigText, which should be big enough. The problem is, that it doesnt work - the text is not assigned. When we assign it like this:
Result.ADDTEXT(MIT.OpenURL(ServiceURL));
and afterwards check the length of the variable, it is always 0.
MESSAGE(FORMAT(Result.LENGTH));
Is there any difference regarding what values can be assigned? Or do you think of any other possiblity? I already tried writing the result directly into a text file - this can also only be 1024 digits at a time. I also wasn't able to do it with a blob field..
If you know what I did wrong, or have any idea how to handle it otherwise, I would be happy for any help.
Thanks for any input,
kola1
0
Best Answer
-
I don't think that Result.ADDTEXT(MIT.OpenURL(ServiceURL)) will let you overcome the 1024 length limit. The reason is that NAV will execute 2 separate commands - try runnig it in debugger and you will have to press F8 twice to pass the line. In between commands the output of MIT.OpenURL() must be stored somewhere before passing it to ADDTEXT - and I guess that would be in some undeclared internal variable.
I guess very the same reason caused the 'direct' write to a file to be limited to 1024 characters.
You need to find a method to pass a file name or a stream to the OCX component, and make the component to write directly to the stream or a file - without passing the data through NAV.
Any code structure like Result.ADDTEXT(MIT.OpenURL(ServiceURL)) constitutes passing the data through NAV. Any construct like this will be subject to maximum NAV text limit.
If your OCX doesn't have any methods where you can pass the file name (or a stream) as a destination of OpenURL you may be forced to use some different component. I believe you may be able to find examples here on mibuso of using some automation components to handle http requests
Slawek
Slawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-031
Answers
-
I don't think that Result.ADDTEXT(MIT.OpenURL(ServiceURL)) will let you overcome the 1024 length limit. The reason is that NAV will execute 2 separate commands - try runnig it in debugger and you will have to press F8 twice to pass the line. In between commands the output of MIT.OpenURL() must be stored somewhere before passing it to ADDTEXT - and I guess that would be in some undeclared internal variable.
I guess very the same reason caused the 'direct' write to a file to be limited to 1024 characters.
You need to find a method to pass a file name or a stream to the OCX component, and make the component to write directly to the stream or a file - without passing the data through NAV.
Any code structure like Result.ADDTEXT(MIT.OpenURL(ServiceURL)) constitutes passing the data through NAV. Any construct like this will be subject to maximum NAV text limit.
If your OCX doesn't have any methods where you can pass the file name (or a stream) as a destination of OpenURL you may be forced to use some different component. I believe you may be able to find examples here on mibuso of using some automation components to handle http requests
Slawek
Slawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-031 -
Maybe you can try this with the automation object XMLHTTP60
OBJECT Codeunit 70000 ReadWebservice { OBJECT-PROPERTIES { Date=22-08-17; Time=15:10:46; Modified=Yes; Version List=; } PROPERTIES { OnRun=BEGIN CallWebservice; END; } CODE { PROCEDURE CallWebservice@1000002() : Text[30]; VAR autXmlHttp@1000016 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 6.0:{88D96A0A-F192-11D4-A65F-0040963251E5}:'Microsoft XML, v6.0'.XMLHTTP60"; TempBlob@1000001 : TEMPORARY Record 99008535; TempInstream@1000002 : InStream; L_Txt@1000005 : Text[1024]; ServiceURL@1000000000 : Text[1024]; BEGIN CLEAR(TempBlob); CLEAR(TempInstream); CLEAR(autXmlHttp); CREATE(autXmlHttp); ServiceURL := 'https://webserviceURL'; autXmlHttp.open('GET', ServiceURL,0); autXmlHttp.setRequestHeader('Content-type','text/xml'); autXmlHttp.send(); TempBlob.Blob.CREATEINSTREAM(TempInstream); TempInstream := autXmlHttp.responseStream; WHILE NOT (TempInstream.EOS()) DO BEGIN TempInstream.READTEXT(L_Txt); //Do want you want with l_Txt END; END; BEGIN END. } }
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