ServerXMLHttp - impossible to set timeouts

lboniventolbonivento Member Posts: 4
Hello,

I try to change timeouts for ServerXMLHttp ('Microsoft XML, v3.0'.ServerXMLHTTP30) by using function settimeouts, but I always receive Timeout error when trying to send to webservice.

Changing timeouts with function "setTimeouts(LONG resolveTimeout, LONG connectTimeout, LONG sendTimeout, LONG receiveTimeout )" don't seems to work because I receive Timeout error each time between 10 and 30 seconds, during execution of function XMLhttp.send(lParams).

Does someone have any idea on what I'm doing wrong ? See my code below :
DSSetup.GET();

CASE ExportType OF
  ExportType::Shop: lUrl := DSSetup."Ondango Shop API url";
  ExportType::Product: lUrl := DSSetup."Ondango Product API url";
  ExportType::Stock:lUrl := DSSetup."Ondango Stock API url";
END;

lParams := 'api_key=' + DSSetup."Ondango API Key";
lParams += '&csv_file=' + DSSetup."Ondango FTP Folder url" + 'export/' + FileName;

IF ISCLEAR(lXMLHTTP) THEN
  CREATE(lXMLHTTP);

lXMLHTTP.open('POST', lUrl, FALSE);

//Send the proper header information along with the request
lXMLHTTP.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
lXMLHTTP.setRequestHeader('Content-length', FORMAT(STRLEN(lParams)));
lXMLHTTP.setTimeouts(99999,99999,99999,99999);

lXMLHTTP.send(lParams);

lResult := FORMAT(lXMLHTTP.status) + ':' + lXMLHTTP.statusText;

Thanks a lot for your help.

Regards,
LBonivento

Comments

  • ara3nara3n Member Posts: 9,256
    use Microsoft WinHTTP Services instead.


    http://mibuso.com/blogs/ara3n/2008/05/1 ... bservices/
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • lboniventolbonivento Member Posts: 4
    Hello ara3n,

    Thanks for your reply.

    I try to change automation and use WinHTTP as you preconize. But I've always the same problem. I use 'Microsoft WinHTTP Services, version 5.1'.WinHttpRequest, and set code like below :
    DSSetup.GET();
    
    CASE ExportType OF
      ExportType::Shop: lUrl := DSSetup."Ondango Shop API url";
      ExportType::Product: lUrl := DSSetup."Ondango Product API url";
      ExportType::Stock:lUrl := DSSetup."Ondango Stock API url";
    END;
    
    lParams := 'api_key=' + DSSetup."Ondango API Key";
    lParams += '&csv_file=' + DSSetup."Ondango FTP Folder url" + 'export/' + FileName;
    
    IF ISCLEAR(lWinHTTP) THEN
      CREATE(lWinHTTP);
    
    lWinHTTP.Open('POST', lUrl, FALSE);
    lWinHTTP.SetRequestHeader('Content-type', 'application/x-www-form-urlencoded');
    lWinHTTP.SetRequestHeader('Content-length', FORMAT(STRLEN(lParams)));
    lWinHTTP.SetTimeouts(999999999,999999999,999999999,999999999);
    
    lWinHTTP.Send(lParams);
    
    lResult := FORMAT(lWinHTTP.Status) + ':' + lWinHTTP.StatusText;
    

    I try changing SetTimeouts value but I received a timeout every time between 15 and 25 seconds.

    Maybe I miss something ?

    Thanks for your help
  • mdPartnerNLmdPartnerNL Member Posts: 802
    An idea'
    create a var dummy or use a integer

    dummy := 99999999;
    then do the lWinHTTP.SetTimeouts(dummy,dummy, etc.
  • lboniventolbonivento Member Posts: 4
    Hmmmm ... I try to create a VARIANT to put as parameter as mentioned. And an Integer too, but always same problem after 25 seconds --> timeout :cry:
  • Anders_M_Z_HAnders_M_Z_H Member Posts: 1
    Hi there
    You have to set the timeot before making the OPEN:

    // Instantiate a WinHttpRequest object.
    var WinHttpReq = new ActiveXObject("WinHttp.WinHttpRequest.5.1");

    // Set time-outs. If time-outs are set, they must
    // be set before open.
    WinHttpReq.SetTimeouts(30000, 30000, 30000, 30000);

    // Initialize an HTTP request.
    WinHttpReq.Open("GET", "http://www.microsoft.com", false);

    // Send the HTTP request.
    WinHttpReq.Send();

    I have not tried it myself (yet) but is assume that it could bee your problem.

    Best regards
    Anders H.
Sign In or Register to comment.