Options

Read A Web Page

ronfoxronfox Member Posts: 3
Hello!

We need to read a web page from Navision and have been unsuccessful in our attempts. The design calls for an integration with another system that uses http post and returns information as a web page. Posting information to the form has been very successful, reading has not.

My question is, "Is there a dirrerent method than this OCX Control to read a web page, or is there a better way to use this control?"


The variable Http is set as an OCX, subtype: Microsoft Internet Transfer Control 6.0 (SP4)

According to everything I have been able to read the openurl function should return a variant that is the page contents. All that we receive is an unprintable character.

Here is the sample code we're attempting to use:
Http.Protocol := 4; //2=FTP, 4=HTTP.
vRemoteHost := 'http://www.google.com';
Http.RequestTimeout := 30;


vVariant := Http.OpenURL(vRemoteHost);
//Http.URL := vRemoteHost;
//vVariant := Http.OpenURL;

//Http.Execute(vRemoteHost,'GET index.htm c:\GotIt.txt');
//vSize := 250;
//vVariant := Http.GetChunk(vSize);

REPEAT
SLEEP(1000);
Counter := Counter + 1;

IF vVariant.ISTEXT THEN MESSAGE('Variant is Text'); //This works!

UNTIL (NOT Http.StillExecuting) OR (Counter = 30);

IF Http.ResponseCode = 0 THEN BEGIN

MESSAGE('Length = %1',STRLEN(vVariant)); // Length is always =1

vtext := COPYSTR(vVariant,1,250);
// vInstream := vVariant;
MESSAGE('Text variant = %1',vText); //Always returns an unprintable character

END;


Thanks!

Comments

  • Options
    lzrlzr Member Posts: 264
    I used XMLHTTP from the MSXML3.0 package when I made a connection to a web page some time ago. This is for posting XML but maybe you can use it.

    Just a comment: Remember the string variable in Navision is max 1024 chars. If you try to put a web page in a string you might have a problem.
    Navision developer
  • Options
    ronfoxronfox Member Posts: 3
    Thanks, will attempt to review the XML path. It just doesn't seem that this should be very difficult and the OCX control "Looks" like it should work!

    The variable that we are reading into is type variant, and then we were using copystr to get a small portion to our text variable.

    Thanks for the ideas.
  • Options
    feriferi Member Posts: 2
    Hello,

    I had to do something similar. I call the openurl function with a url that consists of the server address and some parameters. The server should then generate a new coded url and send it back to navision.

    Then navision should open a browser window and open that new coded url.

    I had the same problem with the return value. Then I changed the type for the return value from "Variant" to "Text" and it worked. This is just for some short return values possible, and not for big sites, as lzr already mentioned. :wink:

    Best Regards
    feri
Sign In or Register to comment.