mardi 24 novembre 2015

How to handle soap response in php

I need to use soap calls for my application so i googled a bit about some libraries in laravel and found one:

Laravel SoapClient Wrapper

It's not documented a lot so i'm kinda stuck. I have successfully retrieved data but cannot display it on page because it is "NULL". So if anyone can help me where i did wrong?

My code is next

//variable is null at beggining
$rac=null;
SoapWrapper::add(function ($service) {
        $service
            ->name('test')
            ->wsdl('http://wdsl-link');
    });

$data = [
        'param' => '111111'
];

SoapWrapper::service('test', function ($service) use ($data) {
        $rac = $service->call('getSmth', [$data])->structure;
        //Tried with sleep so variable $rac can be assigned but no results
        //sleep(5); 
        //dd here works and i got my desired data
        //dd($rac);
    });
//dd don't work here and variable $rac is null
//dd($rac);
return view('pages/...',compact('rac'));

It's not about syntax, it's about my bad understanding of handling soap responses. So if anyone can tell me how to get that response or maybe some advice to use some other library for soap which works with Laravel?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire