Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration with laravel #20

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

manu2319
Copy link

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')
);

@f3l1x
Copy link
Member

f3l1x commented Nov 29, 2017

Thanks for PR. Well, it's big change to nusoap, could you please add some testcase? I wouldn't like to break all systems. :-)

@manu2319
Copy link
Author

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,

@zerobyt
Copy link

zerobyt commented May 29, 2020

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?

@f3l1x f3l1x force-pushed the master branch 2 times, most recently from f034663 to cb4d0dc Compare July 5, 2023 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants