Laravel 5.1使用控制器和模型消耗soap wsdl服务

问题描述 投票:1回答:1

目前我正在使用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我找不到关于如何在任何其他请求之前发送登录参数的教程。在“使用添加的服务”示例中,我看到了登录凭据,但它不起作用。

mysql laravel wsdl laravel-5.1 soap-client
1个回答
2
投票

这就是我在Laravel 5.1中使用肥皂的方法

  1. 清洁安装laravel 5.1
  2. 安装artisaninweb/laravel-soap
  3. 创建一个控制器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')); }); } }
  4. 在routes.php中创建一个路由

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

如果重新加注,你也可以使用here描述的模型扩展

© www.soinside.com 2019 - 2024. All rights reserved.