vendredi 20 septembre 2019

Laravel Gazzel Making multiple requests to same URL without login multiple times

So I have this class setup in laravel. It is using following header to initialize requests.

    $this->xml = "<?xml version=\"1.0\"?>
    <query xmlns=\"http://www.someurl.com/queryLanguage/v1.0\">
        <logon>
            <userName>".config('some.username')."</userName>
            <password>".config('some.password')."</password>
            <deviceName>".config('some.device')."</deviceName>
        </logon>";

Then I have like 10 requests to make to the same url with above auth details.

so im doing it like.

    $xml1 = $this->xml;
    $xml1 .= "some xml";
    $options = [
        'headers' => [
            'Content-Type' => 'text/xml; charset=UTF8',
        ],
        'body' => $xml1,
    ];

    $client = new Client(); 
    $response = $client->request('POST', config('some.apiurl'), $options);

    $xml2 = $this->xml;
    $xml2 .= "some xml";
    $options = [
        'headers' => [
            'Content-Type' => 'text/xml; charset=UTF8',
        ],
        'body' => $xml2,
    ];

    $client = new Client(); 
    $response = $client->request('POST', config('some.apiurl'), $options); 

    $xml3 = $this->xml;
    $xml3 .= "some xml";
    $options = [
        'headers' => [
            'Content-Type' => 'text/xml; charset=UTF8',
        ],
        'body' => $xml3,
    ];

    $client = new Client(); 
    $response = $client->request('POST', config('some.apiurl'), $options); 

as you can see with each requests it makes a new login and eventually ended up getting too many concurrent logons error from remote server. so my question is how we use this api login information and just login once with gazzel and then use it for multiple requests later.

Thanks in advance.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/30lGJ3u
via IFTTT

Aucun commentaire:

Enregistrer un commentaire