XMLHTTP Automation proxy

Troubles_In_ParadiseTroubles_In_Paradise Member Posts: 588
edited 2015-01-21 in NAV Three Tier
Hi guys, I've one question about proxy.
I use an Automation variable to make a connection to a web site to dowload an xmlfile (see code below... process runs via RTC).
Name	DataType	Subtype	Length
XmlHttp	Automation	'Microsoft XML, v6.0'.XMLHTTP60	

IF GUIALLOWED THEN
  Window.OPEN('do you want to start?');

IF ISCLEAR(XmlHttp) THEN
  CREATE(XmlHttp);

XmlHttp.open('GET',"www.mysite.com",FALSE); 

XmlHttp.send; 
IF XmlHttp.status = 200 THEN BEGIN
...
My question is, is there a way to force nav to use a specific proxy?
I've searched the forum and I found this post: viewtopic.php?f=32&t=46478&hilit=proxy+xmlhttp
Here they use .setProxy method that is not available for Xmlhttp variable but only for serverXMLHTTP.
Since I don't know the difference between XMLHTTP and serverXMLHTTP :oops: I simply tried to change the subtype of my automation variable from the first to the latter but with this modification RTC replies with "Application timed out".
has anyone an idea?

Thanks in advance.
~Rik~
It works as expected... More or Less...

Answers

  • Troubles_In_ParadiseTroubles_In_Paradise Member Posts: 588
    I did another test:
    Variables:
    Name	DataType	Subtype	Length
    XMLHTTP	Automation	'Microsoft XML, v6.0'.ServerXMLHTTP60	
    XMLDOC	Automation	'Microsoft XML, v6.0'.DOMDocument
    
    Code:
    IF CONFIRM('Let''s go') THEN BEGIN
    
      IF ISCLEAR(XMLHTTP) THEN
        CREATE(XMLHTTP);
    
      IF ISCLEAR(XMLDOC) THEN
        CREATE(XMLDOC);
     
      XMLHTTP.setProxy(2,'proxy::8080');
      XMLHTTP.open('POST','http://www.google.com',FALSE);
      XMLHTTP.send;
    
      XMLDOC.load(XMLHTTP.responseXML);
      XMLDOC.save('C:\Temp\test.xml');
    
      MESSAGE('done');
    END;
    
    but I receive the following error:
    ---------------------------
    Microsoft Dynamics NAV Classic
    ---------------------------
    This message is for C/AL programmers:
    
    The call to member open failed. msxml6.dll returned the following message:
    The parameter is incorrect.
    
    ~Rik~
    It works as expected... More or Less...
  • Troubles_In_ParadiseTroubles_In_Paradise Member Posts: 588
    Changing Approach I found a solution.
    This is the post that helped me: viewtopic.php?f=23&t=37522&hilit=winhttp
    Variables used:
    Name	DataType	Subtype	Length
    WINHTTP	Automation	'Microsoft WinHTTP Services, version 5.1'.WinHttpRequest	
    _InStream	InStream		
    URL	        Text		1024
    Received	Text		128
    
    Code:
    IF CONFIRM('Let''s go!') THEN BEGIN
    
      URL := 'http://www.google.com';
      
      IF ISCLEAR(WINHTTP) THEN
        CREATE(WINHTTP);
    
      WINHTTP.SetProxy(2,'myproxy:8080');
      WINHTTP.Open('GET',URL,FALSE);
      WINHTTP.Send;
    
      CLEAR(_InStream);
      IF WINHTTP.Status = 200 THEN BEGIN
        _InStream := WINHTTP.ResponseStream;
    
        //do what you want
        _InStream.READTEXT(Received,128);
        MESSAGE(Received);
      END;
    END;
    
    ~Rik~
    It works as expected... More or Less...
  • jaja_bingsjaja_bings Member Posts: 16
    Hi,

    I am aware of this thread is old, but I had an issue in this direction.

    The solution with XMLHTTP should also work, if you use only one colon ':', maybe that was only a typo.

    So instead of
    XMLHTTP.setProxy(2,'proxy::8080');
    
    you have to set
    XMLHTTP.setProxy(2,'proxy:8080');
    
    and it should work.

    It seems also to me that the current user credentials are used, because I do not need to setup these information.

    Kind regards,
    jaja_bings
Sign In or Register to comment.