Does not work the "Soapwrapper" with Laravel

Asked

Viewed 350 times

0

I am trying to consume a WS through application in Aravel 5.6.

That’s the test code:

namespace App\Http\Controllers;
use SoapClient;
use Artisaninweb\SoapWrapper\Facades\SoapWrapper;
use Illuminate\Http\Request;
use App\Soap\Request\GetConversionAmount;
use App\Soap\Response\GetConversionAmountResponse;
use App\Soap;
use App\Soap\Response;

class EducacionalController extends Controller{

protected $soapWrapper;

public function index(Request $request){
    $soap = SoapWrapper::add(function ($service) {
        $service
            ->name('rmFametro')
            ->wsdl('http://sistemas.portaledu.com.br:8051/wsConsultaSQL/MEX?wsdl')
            ->options([
                'login' => 'YYYYYYYY',
                'password' => 'XXXXXXXX'
            ])
            ->trace(true);
    });

     $response = $soap->soapWrapper->call('RealizarConsultaSQL', [
        'codSentenca' => '07', 
        'codColigada' => '1', 
        'codSistema'  => 'S', 
        'parameters'  => 'CPF=99999999999',
    ]);

    var_dump($response);

    }
}

And that’s the error of the test:

Undefined Property: Artisaninweb Soapwrapper Wrapper::$soapWrapper

My settings, in aap.php:

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

.

 'aliases' => [
 ...
 'SoapWrapper' => Artisaninweb\SoapWrapper\Facades\SoapWrapper::class
 ...     
 ];

Erro que obtenho hoje

Where I can’t see error?

1 answer

1


Check the comments

//instancie um novo objecto
$soap = new SoapWrapper; 


//estava a  faltar o primeiro parâmetro 'rmFametro'
$soap->add('rmFametro', function ($service) {
    $service->wsdl('http://sistemas.portaledu.com.br:8051/wsConsultaSQL/MEX?wsdl')
        ->options([
            'login' => 'YYYYYYYY',
            'password' => 'XXXXXXXX'
        ])
        ->trace(true);
});

//verifique a forma correcta de efectuar a chamada
$response = $soap->call('rmFametro.RealizarConsultaSQL', [
    'codSentenca' => '07',
    'codColigada' => '1',
    'codSistema' => 'S',
    'parameters' => 'CPF=99999999999',
]);

var_dump($response);

Update using Controller

add the service Provider in app/config/app.php.

Artisaninweb\SoapWrapper\ServiceProvider::class, 

add alias in app/config/app.php.

'SoapWrapper' => Artisaninweb\SoapWrapper\Facade\SoapWrapper::class,  

Educacionalcontroller.php

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Artisaninweb\SoapWrapper\SoapWrapper;

class EducacionalController extends Controller
{
    protected $soapWrapper;

    public function __construct(SoapWrapper $soapwrapper)
    {
        $this->soapWrapper = $soapwrapper;
    }
    public function index(Request $request)
    {
        $this->soapWrapper->add('rmFametro', function ($service) {
            $service->wsdl('http://sistemas.portaledu.com.br:8051/wsConsultaSQL/MEX?wsdl')
                ->options([
                    'login' => 'YYYYYYYY',
                    'password' => 'XXXXXXXX'
                ])
                ->trace(true);
        });

        $response = $this->soapWrapper->call('rmFametro.RealizarConsultaSQL', [
            'codSentenca' => '07',
            'codColigada' => '1',
            'codSistema' => 'S',
            'parameters' => 'CPF=99999999999',
        ]);

        var_dump($response);

    }

}
  • Error trying to instantiate: Soapwrapper. syntax error, unexpected '$soap' (T_VARIABLE), expecting function (T_FUNCTION) or const (T_CONST)

  • 1

    Used my code or adapted ?

  • Mine is returning "Invalid User or Password! The user or password used for login is not valid for system access. Make sure the user code is correctly typed and write your password. Make sure the CAPS LOCK key is not accidentally pressed."

  • I only adapted where you have: user and password. the rest is the same, you could provide the full class?

  • I just put inside a closure inside a Route ex. Route::get('/', Function () { 'here'})

  • What error are you getting

  • I will add an addition to the question, with a picture illustrating the error!

  • See the updated response

  • To instantiate a new Soapwrapper you must use the constructor

Show 5 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.