Webservice with WinHTTP
24th April 2008
There are several howto on mibuso on how to consume webservices. Most of these examples for example
http://www.mibuso.com/forum/viewtopic.php?t=23618
You can also use WinHTTP
‘Microsoft WinHTTP Services, version 5.1′.WinHttpRequest
Why would you want to use WinHTTP, well it has a SetTimeouts function that allows you to stop waiting for a webservice. So navision doesn’t stop working if you don’t receive a message back.
WinHTTP.Open('POST','http://www.webservicex.net/CurrencyConvertor.asmx',0);
WinHTTP.SetRequestHeader('Content-type','text/xml');
WinHTTP.SetRequestHeader('SOAPAction','http://www.webserviceX.NET/ConversionRate');
WinHTTP.SetTimeouts(1000,1000,1000,1000);
WinHTTP.Send(XmlDoc);
WinHTTP.WaitForResponse(1000);
XmlDoc.async := FALSE;
XmlDoc.load(WinHTTP.ResponseBody);
IF WinHTTP.Status 200 THEN
ERROR('Http Error ' + ' ' + FORMAT(WinHTTP.Status) + ': ' + WinHTTP.StatusText);
October 22nd, 2009 at 2:45 am
WaitForResponse value has to be in seconds not in milliseconds.
WaitForResponse(1000) waits for 1000 seconds which means a wait time of 16 minutes 40 seconds.
SetTimeouts values are in milliseconds but WaitForResponse is in seconds.