目前我正在使用php和nusoap,并希望将其转换为Laravel。
创建soap调用时,我使用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中,我找不到关于如何在任何其他请求之前发送登录参数的教程。在“使用添加的服务”示例中,我看到了登录凭据,但它不起作用。

最佳答案

这就是我如何让肥皂在拉维尔5.1工作
清洁安装拉弗5.1
安装artisaninweb/laravel-soap
创建控制器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']);
如果重新查询,您还可以使用模型扩展,如所述here

关于mysql - Laravel 5.1使用 Controller 和模型消耗Soap wsdl服务,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/33314045/

10-12 22:22
查看更多