Page 1 of 1

Soap Web Service - timeout request

PostPosted: Mon Jan 08, 2024 9:13 pm
by cdmmaui
Hello,

It is possible to set a timeout request for a web service request? I added to IF oHttp:status=200 to check status but sometimes request hangs.

TRY
oHttp := CreateObject( 'MSXML2.XMLHTTP' )
CATCH
oHttp := CreateObject( 'Microsoft.XMLHTTP' )
END

cHttpSend := [<?xml version="1.0"?>]
cHttpSend += [<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:abc.com:05-OfferToCash:40-LogisticDelivery">]
cHttpSend += [ <soapenv:Header/>]
cHttpSend += [ <soapenv:Body>]
cHttpSend += [ <urn:FindRFIDQry>]
cHttpSend += [ <!--Optional:-->]
cHttpSend += [ <Header>]
cHttpSend += [ <!--Optional:-->]
cHttpSend += [ <Document>] + cSDNo + [</Document>]
cHttpSend += [ <!--Optional:-->]
cHttpSend += [ <OutboundDelivery></OutboundDelivery>]
cHttpSend += [ </Header>]
cHttpSend += [ </urn:FindRFIDQry>]
cHttpSend += [ </soapenv:Body>]
cHttpSend += [</soapenv:Envelope>]

oHttp:Open( 'POST', cURL, .F. )
oHttp:SetRequestHeader( "Content-Type","application/xml")
oHttp:SetRequestHeader( "Accept","*/*")
oHttp:SetRequestHeader( "Authorization", "Basic "+hb_base64Encode(cCred))
oHttp:Send( cHttpSend )
Sysrefresh()
IF oHttp:status=200
cWinResp := oHttp:ResponseBody
ENDIF

Re: Soap Web Service - timeout request

PostPosted: Tue Jan 09, 2024 6:34 am
by Antonio Linares
Dear Darrell,

Please try this:

oHttp:Open( 'POST', cURL, .F. )
oHttp:SetRequestHeader( "Content-Type","application/xml")
oHttp:SetRequestHeader( "Accept","*/*")
oHttp:SetRequestHeader( "Authorization", "Basic "+hb_base64Encode(cCred))
oHttp:Send( cHttpSend )
oHttp:WaitForResponse( nSecs )
Sysrefresh()
IF oHttp:status=200
cWinResp := oHttp:ResponseBody
ENDIF

Re: Soap Web Service - timeout request

PostPosted: Tue Jan 09, 2024 12:47 pm
by cdmmaui
Hi Antonio,
Thank you. Question, if I set nSecs = 5 and responses comes back faster, will it still wait 5 seconds or process immediately?

Re: Soap Web Service - timeout request

PostPosted: Tue Jan 09, 2024 4:36 pm
by nageswaragunupudi
cdmmaui wrote:Hi Antonio,
Thank you. Question, if I set nSecs = 5 and responses comes back faster, will it still wait 5 seconds or process immediately?

Does not wait.
Processes immediately.

Also for additional information:
httprequest method
SetTimeOuts( nResolveTimeOut, nConnectTimeOut, nSendTimeOut, nReceiveTimeOut)
All times in milli-seconds

Re: Soap Web Service - timeout request

PostPosted: Thu Jan 11, 2024 6:50 pm
by RSalazarU
Darrell

intenta con 'MSXML2.ServerXMLHTTP' que tiene el metodo setTimeouts(lResolve, lConnect, lSend, lReceive)

'MSXML2.XMLHTTP' es distinto de 'MSXML2.ServerXMLHTTP'

Yo lo uso asi
Code: Select all  Expand view

oHttp := CreateObject( 'MSXML2.ServerXMLHTTP' )
oHttp:setTimeouts(  5 * 1000,   5 * 1000,  30 * 1000,  30 * 1000) //V1.1 ok
 


Atentamente

Rolando
Cochabamba - Bolivia