1. Praveen Rajarao
  2. PowerBuilder
  3. Tuesday, 6 August 2019 18:57 PM UTC

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

Praveen Rajarao Accepted Answer Pending Moderation
  1. Monday, 12 August 2019 14:03 PM UTC
  2. PowerBuilder
  3. # 1

Roland - I am starting a new Response thread, since the previous one doesnt allow me to attach any documents. Also I can't paste an XML, it does some sort of pre-formatting and removes all tags. 

So here goes.

The URL I am calling is not exposed outside our firewall, so you may not be able to test it from your end. I have included the URL and Response (sample) in the doc attached. 

From the n_winhttp object I am expecting the entire Response to be returned and captured. It is how the POST works, not sure why the GET isn't doing the same. 

If we can get this working, that will be the optimum solution for the problem I am facing. 

I hope you have some time to look into this. 

Thanks and appreciate.

Praveen.

 

Attachments (1)
Comment
  1. Roland Smith
  2. Monday, 12 August 2019 17:37 PM UTC
Your attachment has 4096 characters in the returned XML, exactly 4K.



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.
  1. Helpful
  1. Praveen Rajarao
  2. Monday, 12 August 2019 18:30 PM UTC
Roland - The original Response XML is way bigger than that. I just took a sub-set of it. Let me try to debug and see whether there is any error. I dont think the issue is with the timeout. But let me verify that.
  1. Helpful
  1. Praveen Rajarao
  2. Thursday, 15 August 2019 18:37 PM UTC
Roland - I got the winhttp object to work for my GET requests with a 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
  1. Helpful
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Wednesday, 7 August 2019 13:06 PM UTC
  2. PowerBuilder
  3. # 2
Comment
  1. Praveen Rajarao
  2. Friday, 9 August 2019 20:25 PM UTC
First, the XMLHTTP does not support the setTimeOuts method.

Second, I tried the WinHTTP for the GetURL. It does not return me the complete XML that is returned by the service. The PostURL works great. WinHTTP would be my first choice if I could do GET calls.

The GetURL method returns only tags which have values I think. So the very first tag with the namespace is not returned which I definitely need. In essence, I would like the GetURL to return similar to how the PostURL returns me the complete URL.

Hey, thanks for all the quick responses. Really appreciate your time.

  1. Helpful
  1. Roland Smith
  2. Friday, 9 August 2019 20:32 PM UTC
Send me a copy of of your WinHTTP test app with the URL, I'll look into it over the weekend. Click the Contact link on the website to get my email.
  1. Helpful
  1. Sarath Pappireddy
  2. Friday, 9 August 2019 20:37 PM UTC
I have tried with multiple options also like what roland explained above earlier itself.but control is returning without any response immediately. Praveen can you send the sample piece of code what you did for the timeouts?i am getting error,so help me on this?
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.