0

I've been finding a solution to this problem that I had. Please take note that I am new in Laravel but fluent in PHP.

From routes/web.php

Route::any('/server', 'SoapController@callServer'); Route::get('/client', function() { $params = array( 'location' => 'http://localhost/soap/public/server' ,'uri' => 'urn://localhost/soap/public/server' ,'trace' => 1 ); $client = new \SoapClient(null, $params); $id_array = array('id' => '1'); echo $client->__soapCall('getStudentName', $id_array); }); 

From SoapController.php

namespace App\Http\Controllers; use Illuminate\Http\Request; use App\Server; class SoapController extends Controller { public function callServer() { $params = array('uri' => 'soap/public/server'); $server = new \SoapServer(null, $params); $server->setClass('App\Server'); $server->handle(); } } 

From app/Server.php

namespace App; class Server { public function getStudentName($id_array) { return 'Student Name'; } } 

When I run http://localhost/soap/public/server, it is working fine. But when I run http://localhost/soap/public/client Laravel produces error "unknown status".

Only the __soapCall() line produces error. The parameters were successfully transferred to the function.

Please help.

1 Answer 1

1

Edit app/Http/Middleware/VerifyCsrfToken.php in your laravel app to white-list your server url from CSRF verification like this:

class VerifyCsrfToken extends Middleware { /** * The URIs that should be excluded from CSRF verification. * * @var array */ protected $except = [ '*/images/upload', '*/search', '*/server' // add your server uri here. ]; } 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.