Highlighted
Frequent Visitor.
205 views

Issue with polling request

Hi Team,

I'm currently working with LR 12.6 - web(http/html) protocol - URL mode. Application is sharepoint based with webservices calls to populate the form details.

I have recorded the script, correlated and done automatic ASYNC call scan and applied the same.

Problem: when the Async call is started only the primary request is getting 200 response. All other polling requests are getting failed  with response message : 400 Bad Request.

from my observation I noticed that polling requests are having ENCTYPE as "TEXT/HTML". However the initial primary request has ENCTYPE as "APPLICATION/JSON". Im not sure where to change this and make it reflect as "Application/json" in the polling request and How can I make this request PASS.

please let me know if you have came across this issue or am I missing anything?

Below the script snippets :

Action:

web_reg_async_attributes("ID=LongPoll_0", 
        "Pattern=LongPoll", 
        "URL=XXXXXXXXXXXXX/InvokeDynamicAssemblyMethodHandler?", 
        "RequestCB=LongPoll_0_RequestCB",    
        "ResponseCB=LongPoll_0_ResponseCB", 
        LAST);

web_custom_request("InvokeDynamicAssemblyMethodHandler",

"URL=XXXXXXXXXXXXX/InvokeDynamicAssemblyMethodHandler?", 

"Method=POST",

"RecContentType=application/json",

"Resource=0",

"Body=XXXXX",

LAST);

web_sync("ParamCreated=ready","RetryIntervalMs=30000","RetryTimeoutMs=120000",LAST);
web_stop_async("ID=LongPoll_0",    LAST);

Asynccallback.c

int LongPoll_0_RequestCB()
{
    //Enter your implementation for RequestCB() here.

    //Call web_util_set_request_url() here to modify request URL:
    //web_util_set_request_url("<request url>");

    //Call web_util_set_request_body() here to modify request body:
    //TODO - Use snapshot view to see examples of request bodies sent.
    //web_util_set_request_body("<request body>");    
    
    return WEB_ASYNC_CB_RC_OK;
}

int LongPoll_0_ResponseCB(
    const char *    aResponseHeadersStr,
    int                aResponseHeadersLen,
    const char *    aResponseBodyStr,
    int                aResponseBodyLen,
    int             counter,
    int                aHttpStatusCode)
{
    //Enter your implementation for ResponseCB() here.

    //TODO - To make the script wait for a specific response, use web_sync in the relevant Action file.
    //See the Modifying Callbacks section in the VuGen user guide for more details.
    
    //enter your implementation for ResponseCB() here
    //Increment long-polling response counter
    counter++;
    //Set parameter value to indicate that 10 long-polling responses were received.
    if (counter>2 || (strcmp(aHttpStatusCode,"200") == 0))
        {
            lr_save_string("OK","ready");
        }

    return WEB_ASYNC_CB_RC_OK;
}

 

 

 

0 Likes
1 Reply
Highlighted
Acclaimed Contributor.
Acclaimed Contributor.

Recent I was fighting with async calls as well. I noticed that some not all headers are preserved, but when you setup an auto-header it is preserved with each async call. So you should try to add to your call web_custom_request() the argument

"EncType=application/json"

or add it as an web_add_auto_header("Content-Type", "application/json") and stop it after your web_custom_request.

Checkout also the help on web_custom_request's Attributes and look to EncType, RecContentType and Resource.

 

 

Signature:
Reward community members who take time to respond and help.
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.