PROCEDURE GetURL@1000000001(VAR response@1000000007 : BigText;url@1000000009 : Text[1024];VAR timeout@1000000001 : Integer) : Boolean; VAR httpRequest@1000000002 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 6.0:{F6D90F16-9C73-11D3-B32E-00C04F990BB4}:'Microsoft XML, v6.0'.XMLHTTP"; WinHttpRequest@1000000003 : Automation "{662901FC-6951-4854-9EB2-D9A2570F2B2E} 5.1:{2087C2F4-2CEF-4953-A8AB-66779B670495}:'Microsoft WinHTTP Services, version 5.1'.WinHttpRequest"; elapsed@1000000005 : Integer; TimeBegin@1000000006 : Time; IStream@1000000010 : InStream; BEGIN CREATE(httpRequest); httpRequest.open('GET',url,TRUE); // True - Does not work ? // False - Works only when ETH connection is UP TimeBegin:=TIME; httpRequest.send(); COMMIT; REPEAT BEGIN elapsed:=TIME-TimeBegin; IF (elapsed>=timeout) THEN BEGIN CLEAR(httpRequest); EXIT(FALSE) END; END; UNTIL ((httpRequest.readyState() = 4)); IF NOT (httpRequest.status = 200) THEN BEGIN CLEAR(httpRequest); EXIT(FALSE); END; IStream:= httpRequest.responseStream(); CLEAR(httpRequest); CLEAR(response); response.READ(IStream); timeout:=timeout-elapsed; EXIT(TRUE); END;
PROCEDURE GetURL@1000000001(VAR response@1000000007 : BigText;url@1000000009 : Text[1024];VAR timeout@1000000001 : Integer) : Boolean; VAR httpRequest@1000000002 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 6.0:{F6D90F16-9C73-11D3-B32E-00C04F990BB4}:'Microsoft XML, v6.0'.XMLHTTP"; WinHttpRequest@1000000003 : Automation "{662901FC-6951-4854-9EB2-D9A2570F2B2E} 5.1:{2087C2F4-2CEF-4953-A8AB-66779B670495}:'Microsoft WinHTTP Services, version 5.1'.WinHttpRequest"; elapsed@1000000005 : Integer; TimeBegin@1000000006 : Time; IStream@1000000010 : InStream; BEGIN CREATE(WinHttpRequest); WinHttpRequest.Open('GET',url,TRUE); TimeBegin:=TIME; WinHttpRequest.Send; IF NOT WinHttpRequest.WaitForResponse(timeout) THEN EXIT(FALSE); timeout:=TIME-TimeBegin; IF NOT (WinHttpRequest.Status =200) THEN EXIT(FALSE); IStream := WinHttpRequest.ResponseStream; response.READ(IStream); CLEAR(IStream); CLEAR(WinHttpRequest); EXIT(TRUE); END;
Comments
OnRun()
CRMSetupL.GET;
CREATE(HTTPL);
HTTPL.open('GET', CRMSetupL."Bonus Server Url", FALSE);
HTTPL.send('<hello></hello>');
IF HTTPL.status <> 200 THEN;
So, before getting some url I check the connection:
SendRequest()
IF NOT TestHTTPConnection.RUN() THEN ERROR(ConnectionFailed);
Detail information in my article: http://x-dynamics.blogspot.com/2011/06/interaction-with-web-service-from-nav.html
Hope this helps!
Follow my blog at http://x-dynamics.blogspot.com
Follow my blog at http://x-dynamics.blogspot.com