Integration with laravel
In the controller use this:
$server->framework = 'laravel'; $server->route_class = "App\Http\Controllers"; $server->register("class.hello", array('nombre' => 'xsd:string'), array('return' => 'xsd:string') );
Thanks for PR. Well, it's big change to nusoap, could you please add some testcase? I wouldn't like to break all systems. :-)
Sorry my english is bad.
first install nusoap:
composer require econea/nusoap
Hello, this is my Controller in Laravel #App\Http\Controllers
I have added two properties, which are:
this property is to add the used framework
$server->framework = 'laravel';
this property is to add the driver path
$server->route_class = "App\Http\Controllers";
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use soap_server;
use soapval;
class soapOntas extends Controller
{
//
public function index(){
$URL = "http://localhost/soap";
$namespace = $URL . '?wsdl';
//using soap_server to create server object
$server = new soap_server();
$server->configureWSDL('OntasSave', $namespace, $namespace);
//register a function that works on server
$server->framework = 'laravel';
$server->route_class = "App\Http\Controllers";
$server->register("soapOntas.hello",
array('name' => 'xsd:string'),
array('return' => 'xsd:string')
);
// create the function
// create HTTP listener
if ( !isset( $HTTP_RAW_POST_DATA ) ) {
$HTTP_RAW_POST_DATA = file_get_contents( 'php://input' );
}
$server->service($HTTP_RAW_POST_DATA);
exit();
}
public function hello($name){
return new soapval('return', 'xsd:string', $name);
}
}
in my route:
#Routes\
<?php
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('/', function () {
return view('welcome');
});
Route::any('/soap', 'soapOntas@index');
in my Middleware:
#App\Http\Middleware
edit the file VerifyCsrfToken
add the route
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
class VerifyCsrfToken extends Middleware
{
/**
* The URIs that should be excluded from CSRF verification.
*
* @var array
*/
protected $except = [
"soap"
];
}
regards,
Hello, I am trying to install nusoap server with laravel 7 but the next properties I think they don't work anymore
$server->framework = 'laravel'; $server->route_class = "App\Http\Controllers";
will you happen to have an example of its implementation in a laravel controller?