我正在使用Laravel 上的第一个Soap程序,我正在使用 Laravel SoapClient Wrapper并且能够在我的应用程序上安装它而没有任何问题。
在那个例子之后,我遇到了一个错误,这让我感到震惊,因为我还没有得到它的解决方案。
如果有人可以告诉我为什么会遇到这种不寻常的错误,我将不胜感激
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();
});
}
}
我收到错误
FatalThrowableError (E_ERROR)
Call to a member function add() on null