Hello,
I am looking to set a TimeOut for my REST calls from PB12.5.2. Below is my code:
loo_xmlhttp = CREATE oleobject
loo_xmlhttp.ConnectToNewObject("Msxml2.ServerXMLHTTP.6.0")
loo_xmlhttp.setTimeouts(100,100,100,100)
// invoke POST method for REST web service
loo_xmlhttp.open (astr_rs.in_method_type, is_url_send, false)
// building HTTP request headers
lblb_args = blob(astr_rs.in_arg_data)
ll_length = Len(lblb_args)
loo_xmlhttp.setRequestHeader("Content-Type", is_headers_content_type)
loo_xmlhttp.setRequestHeader("Content-Length", String( ll_length ))
loo_xmlhttp.setRequestHeader("Authorization", "Basic " + is_headers_authorization)
loo_xmlhttp.setRequestHeader("If-Modified-Since", string(today()))
loo_xmlhttp.setRequestHeader("Accept", 'text/xml')
// send request XML
loo_xmlhttp.send(astr_rs.in_arg_data)
// response from the service
ls_status_text = loo_xmlhttp.StatusText
ll_status_code = loo_xmlhttp.Status
ls_response_text = loo_xmlhttp.ResponseText
The highlighted line of code is where I am setting a really low timeout interval (200ms).
But I do not see that working. The service is taking close to 10secs to return and the Send function waits for that time.
How do I achieve it? My aim is to set a timeout and close connection and return control to the application.
Thanks
Praveen
I suggest setting a debug break at line 129 of the senddata function and waking through, one of the function calls must be getting an error or WinHttpQueryDataAvailable is returning zero for lul_size before it is finished. It could be that your timeout is too low to allow for all the data to be returned. See what happens when you use the default timeout.
The only change I did was to add Content-Type as text / xml. That gives me back the complete response including the namespace etc.
The timeout works just like it did for PostURL.
Thanks for the help
Praveen