vendredi 1 juin 2018

Laravel 5.5.40 - SOAP - FatalThrowableError Call to a member function add() on null

I am witting my very Soap program on Laravel and i am using Laravel SoapClient Wrapper and was able to install it on my application without any issues.

Following there example, i encountered an error which blew me away since i have not been able to get a solution for it yet.

Would appreciate if someone can guild me on why i am having this unusual error

ROUTE

Route::get('/currency', ['as' => 'currency', 'uses' => 'SoapController@show']);

CONTROLLER

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use Artisaninweb\SoapWrapper\SoapWrapper;
use App\Soap\Request\GetConversionAmount;
use App\Soap\Response\GetConversionAmountResponse;


class SoapController extends Controller{

/**
 * @var SoapWrapper
 */
protected $soapWrapper;


/**
 * SoapController constructor.
 *
 * @param SoapWrapper $soapWrapper
 */
public function _construct(SoapWrapper $soapWrapper)
{
    $this->soapWrapper = $soapWrapper;
}


/**
 * Use the SoapWrapper
 */
public function show()
{
    $this->soapWrapper->add('Currency', function ($service) {
        $service
            ->wsdl('http://currencyconverter.kowabunga.net/converter.asmx?WSDL')
            ->trace('true')
            ->classmap([
                GetConversionAmount::class,
                GetConversionAmountResponse::class
            ]);

        // Without classmap
        $response = $this->soapWrapper->call('Currency.GetConversionAmount', [
            'CurrencyFrom' => 'USD',
            'CurrencyTo' => 'EUR',
            'RateDate' => '2014-06-05',
            'Amount' => '1000'
        ]);

        var_dump($response);

        // With classmap
        $response-> $this->soapWrapper->call('Currency.GetConversionAmount',
            [
                new GetConversionAmount('USD', 'EUR', '2014-06-05', '1000')
            ]);

        var_dump($response);
        exit();

    });

}
}

I get the error

FatalThrowableError (E_ERROR)
Call to a member function add() on null

Screenshot of the Error Message



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire