Soap Web Service - timeout request

Soap Web Service - timeout request

Postby cdmmaui » Mon Jan 08, 2024 9:13 pm

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
*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com
User avatar
cdmmaui
 
Posts: 689
Joined: Fri Oct 28, 2005 9:53 am
Location: Houston ∙ Chicago ∙ Los Angeles ∙ Miami ∙ London ∙ Hong Kong

Re: Soap Web Service - timeout request

Postby Antonio Linares » Tue Jan 09, 2024 6:34 am

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
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Soap Web Service - timeout request

Postby cdmmaui » Tue Jan 09, 2024 12:47 pm

Hi Antonio,
Thank you. Question, if I set nSecs = 5 and responses comes back faster, will it still wait 5 seconds or process immediately?
*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com
User avatar
cdmmaui
 
Posts: 689
Joined: Fri Oct 28, 2005 9:53 am
Location: Houston ∙ Chicago ∙ Los Angeles ∙ Miami ∙ London ∙ Hong Kong

Re: Soap Web Service - timeout request

Postby nageswaragunupudi » Tue Jan 09, 2024 4:36 pm

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
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10247
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Soap Web Service - timeout request

Postby RSalazarU » Thu Jan 11, 2024 6:50 pm

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
RSalazarU
 
Posts: 211
Joined: Wed Jul 16, 2008 12:59 pm
Location: Cochabamba-Bolivia


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot], richard-service and 59 guests