目前,我正在使用php和nusoap,并希望将其转换为Laravel。
创建肥皂调用时,我使用mysql数据库中的数据。
所以我认为我需要一个模型(获取我的数据)和一个控制器(创建请求)。
编辑:
<?php
namespace App\Http\Controllers;
use Artisaninweb\SoapWrapper\Facades\SoapWrapper;
class SoapController extends Controller {
public function demo()
{
// Add a new service to the wrapper
SoapWrapper::add(function ($service) {
$service
->name('currency')
->wsdl('path/to/wsdl')
->trace(true);
->options(['user' => 'username', 'pass' => 'password']);
});
// Using the added service
SoapWrapper::service('currency', function ($service) {
var_dump($service->getFunctions());
var_dump($service->call('Otherfunction'));
});
}
}
从laravel-soap我找不到如何在任何其他请求之前发送登录参数的教程。在示例“使用添加的服务”中,我看到了登录凭据,但是它不起作用。
这就是我如何在Laravel 5.1中使用肥皂
创建一个控制器SoapController.php
<?php
namespace App\Http\Controllers;
use Artisaninweb\SoapWrapper\Facades\SoapWrapper;
class SoapController extends Controller {
public function demo()
{
// Add a new service to the wrapper
SoapWrapper::add(function ($service) {
$service
->name('currency')
->wsdl('path/to/wsdl')
->trace(true);
});
$data = [
'user' => 'username',
'pass' => 'password',
];
// Using the added service
SoapWrapper::service('currency', function ($service) use ($data) {
var_dump($service->call('Login', [$data]));
var_dump($service->call('Otherfunction'));
});
}
}
在routes.php中创建一条路线
Route::get('/demo', ['as' => 'demo', 'uses' => 'SoapController@demo']);
如果您requered也可以用模型扩展为描述这里
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句