如何将纯soap php转换为laravel 5

如何将纯soap php转换为laravel 5,soap,laravel-5,Soap,Laravel 5,我是拉雷维尔5号的新手。这段代码在纯php中没有问题。但我不知道如何把它转换成拉威尔5。你能告诉我怎么把这个密码传给拉威尔5号吗 client.php: <?php class client { public function __construct() { $params = array('location' => 'http://localhost:8888/csoap/server.php', 'uri' => 'urn:/

我是拉雷维尔5号的新手。这段代码在纯php中没有问题。但我不知道如何把它转换成拉威尔5。你能告诉我怎么把这个密码传给拉威尔5号吗

client.php:

<?php class client {
public function __construct()
{
    $params = array('location' => 'http://localhost:8888/csoap/server.php',
                    'uri' => 'urn://localhost:8888/csoap/server.php');

    /* Initialize webservice */
    $this->instance = new SoapClient(NULL, $params);
}

public function getString($id)
{
    return $this->instance->__soapCall('getOutputString', $id);
}
}

$client = new client();
$id = array('id' => '1');

echo $client->getString($id);
?>
运行:composer安装或composer更新

在config/app.php中添加服务

'providers' => [ 
...
...
Artisaninweb\SoapWrapper\ServiceProvider', 
]

'aliases' => [
...
...
'SoapWrapper' => 'Artisaninweb\SoapWrapper\Facades\SoapWrapper'
]
这是我的客户端soap:
use Artisaninweb\SoapWrapper\Facades\SoapWrapper;

class DataSoap {

public function demo()
{
    // Add a new service to the wrapper
    SoapWrapper::add(function ($service) {
        $service
            ->name('mydata')
            ->wsdl('http://localhost:8888/csoap/Server.php')
            ->trace(true)
    });

    $data = [
        'str' => 'Hello World',
    ];

    // Using the added service
    SoapWrapper::service('mydata', function ($service) use ($data) {
        var_dump($service->getFunctions());
        var_dump($service->call('getString', [$data])->getSringResult);
    });
}
}
当我运行这个代码时,我得到一个错误

Class 'Artisaninweb\SoapWrapper\ServiceProvider' not found
您应该更改:

Artisaninweb\SoapWrapper\ServiceProvider
致:

而且:

SoapWrapper' => 'Artisaninweb\SoapWrapper\Facades\SoapWrapper
致:


也许可以尝试使用一个包:@haakym在何处以及如何放置这些类的别名('ArtisInWeb\SoapWrapper\Facades\SoapWrapper','SoapWrapper');您使用的是lumen还是laravel?在上面的代码中,我使用的是纯php,但我想将其转换为laravel 5.1。现在我遇到了一个错误。。。ProviderRepository.php第146行中的FatalErrorException:未找到类'ArtisInWeb\SoapWrapper\ServiceProvider',在使用L5的::类语法更新config/app.php后也要注意
Artisaninweb\SoapWrapper\ServiceProvider
Artisaninweb\SoapWrapper\ServiceProvider::class
SoapWrapper' => 'Artisaninweb\SoapWrapper\Facades\SoapWrapper
SoapWrapper' => Artisaninweb\SoapWrapper\Facades\SoapWrapper::class