laravel-soap
laravel-soap copied to clipboard
Server was unable to process request. Object reference not set to an instance of an object.
Hello, i use laravel 5.6 running under PHP 7.2.3 and i've got the following error exception generated by laravel-soap library: SoapFault | Arguments | Server was unable to process request. ---> Object reference not set to an instance of an object.
Here is my code:
$this->soapWrapper->add('Piraeus', function ($service){
$service
->wsdl('https://paycenter.piraeusbank.gr/services/tickets/issuer.asmx?WSDL')
->trace(true);
});
$params = array(
//HIDING PARAMETERS VALUE WITH ASTERISK FOR SECURITY REASONS
'Request' => array(
'Username' => "*******",
'Password' => md5('*******'),
'MerchantId' => *******,
'PosId' => *******,
'AcquirerId' => *******,
'MerchantReference' => '*******',
'RequestType' => '*******',
'ExpirePreauth' => *******,
'Amount' => *******,
'CurrencyCode' => *******,
'Installments' => *******,
'Bnpl' => *******,
'Parameters' => '*******'
)
);
$result = $this->soapWrapper->call(
'Piraeus.IssueNewTicket',
['Request' => $params]
);
var_dump($result);
Did you find an answer to this? I'm seeing the same thing.
@fusionconsulting Yes i found, in my case previously i used this code within a controller method, what i've done is that i placed this code directly in web routes function and worked. So under routes folder, in web.php or api.php file in the head of file place:
use Artisaninweb\SoapWrapper\SoapWrapper;
use Illuminate\Http\Request;
Then create a route:
Route::get('/my-route', function(Request $request, SoapWrapper $soapWrapper){
//The code above
});
Thanks for the reply. I actually solved it here by wrapping my parameter array in another array (as found on another issue).
@fusionconsulting You're welcome!
How you fixed @fusionconsulting ? Please can you help to provide sample code? I don't want to write code in routes.
@devateminent Check this out!
Let's suppose you have a method called myFun()
inside your controller.
// Inside file MySampleController.php
// The method myFun() to use SoapWrapper
public function myFun() {
// Define SoapWrapper
$soapWrapper = new \Artisaninweb\SoapWrapper\SoapWrapper;
// The rest of your code here!
}
Please tell me if works :)
@vasileios-tsakalis thanks for reply!
But it is not working.
Below is my soap api
https://domains.livedns.co.il/API/DomainsAPI.asmx?op=Whois
and here is my function
public function show() {
$soapWrapper = new \Artisaninweb\SoapWrapper\SoapWrapper;
$soapWrapper->add('Domain', function ($service) {
$service
->wsdl('https://domains.livedns.co.il/API/DomainsAPI.asmx?WSDL')
->trace(true);
});
// Without classmap
$response = $soapWrapper->call('Domain.Whois', [
'DomainName' => 'string',
'AvailableForRegisterList' => 'string'
]);
var_dump($response);
die;
}
@vasileios-tsakalis @fusionconsulting Kindly help I have tried so many things but not worked :(
@devateminent You're welcome mate! Maybe i can help you! Can you provide more information about how to call services from the provided domains.livedns.co.il soap, like a manual. I'm telling this because i tried with the address you provided and the soap works like a charm. I'm sure the error is on soap call method, maybe you don't call the right parameters.
@vasileios-tsakalis thanks for reply!
In my previous comment, I mention api URL and my code that is calling it. Please let me know what else should I provide to you?
Soap call code:
$soapWrapper = new \Artisaninweb\SoapWrapper\SoapWrapper;
$soapWrapper->add('Domain', function ($service) {
$service
->wsdl('https://domains.livedns.co.il/API/DomainsAPI.asmx?WSDL')
->trace(true);
});
// Without classmap
$response = $soapWrapper->call('Domain.Whois', [
'DomainName' => 'google',
'AvailableForRegisterList' => 'com'
]);
API Sample: https://domains.livedns.co.il/API/DomainsAPI.asmx?op=Whois
Thanks again :)
@devateminent Check this ;)
public function myFun() {
$soapWrapper = new \Artisaninweb\SoapWrapper\SoapWrapper;
$client = $soapWrapper->add('Domain', function ($service) {
$service
->wsdl('https://domains.livedns.co.il/API/DomainsAPI.asmx?WSDL')
->trace(true);
});
$params = [
'DomainName' => 'greetingsfromgreece.com' // :)
];
$response = $soapWrapper->call(
'Domain.Whois',
['op' => $params]
);
var_dump($response);
}
@devateminent Did you fixed the issue?
@vasileios-tsakalis You did for me. Solution works perfect.
Hello, I made all the above but still I get an
Server was unable to process request. ---> Object reference not set to an instance of an object.
from Piraeus, any suggestions ?
Thanks
@kastony Kalispera patrioti. Send me your code to find a solution
@kastony Kalispera patrioti. Send me your code to find a solution Καλησπέρα, ενώ σε άλλα webservices που έχω στην ίδια εφαρμογή δεν έχω πρόβλημα στην pireaus μου βγάζει Server was unable to process request. ---> Object reference not set to an instance of an object. βάζοντας φυσικά τα στοιχεία που μου έχει δώσει η τράπεζα, δοκιμές κάνω από το PC που κάνω development αλλά έκανα και δοκιμή στο live site μήπως και η τράπεζα κοιτάει την IP που έχω δήλωση αλλά τα ίδια.
public function newTicket() {
$soapWrapper = new \Artisaninweb\SoapWrapper\SoapWrapper;
$client = $soapWrapper->add('Piraeus', function ($service) {
$service
->wsdl('https://paycenter.piraeusbank.gr/services/tickets/issuer.asmx?WSDL')
->trace(true);
});
$params = [
'Username' => '',
'Password' => md5(''),
'MerchantId' =>,
'PosId' =>,
'AcquirerId' =>,
'MerchantReference' => '',
'RequestType' => '',
'ExpirePreauth' => ,
'Amount' => ,
'CurrencyCode' =>,
'Installments' => ,
'Bnpl' => ,
'Parameters' => ''
];
$response = $soapWrapper->call(
'Piraeus.IssueNewTicket',
['op' => $params]
);
// var_dump($response);
return $response;
}
@kastony Καλησπέρα και πάλι. Λοιπόν, ακολούθησε τα παρακάτω.
Εφόσον χρησιμοποιείς controller
- Τοποθέτησε τη χρήση του instance κάτω από το namspace και πρίν την έναρξη της κλάσης.
<?php
// namespace here
namespace App\Http\Controllers;
use Artisaninweb\SoapWrapper\SoapWrapper;
<-----
// Begin of class here
class ExampleController extends Controller {.....}
- Θέσε ως παράμετρο του function σου το instance και ακολούθησε τα παρακάτω
public function newTicket(SoapWrapper $soapWrapper) {
$client = $soapWrapper->add('Piraeus', function ($service) {
$service->wsdl('https://paycenter.piraeusbank.gr/services/tickets/issuer.asmx?WSDL')
->trace(true);
});
$params = array(
'Request' => array(
'Username' => "",
'Password' => hash('md5', '*************'),
'MerchantId' => '',
'PosId' => '',
'AcquirerId' => '',
'MerchantReference' => '',
'RequestType' => '',
'ExpirePreauth' => '',
'Amount' => '',
'CurrencyCode' => '',
'Installments' => '',
'Bnpl' => '',
'Parameters' => ''
)
);
$result = $soapWrapper->call(
'Piraeus.IssueNewTicket',
['Request' => $params],
'http://piraeusbank.gr/paycenter/redirection',
'http://piraeusbank.gr/paycenter/redirection/IssueNewTicket'
);
$result_to_array = (array) $result;
$ticket_to_array = (array) $result_to_array['IssueNewTicketResult'];
foreach($ticket_to_array as $res => $value ) {
$$res = $value;
}
if ($ResultCode == 0) {
$piraeus_ticket_response = array(
'Status' => 'Succeed',
'TransactionTicket' => $TranTicket,
'PosId' => $params['Request']['PosId'],
'AcquirerId' => $params['Request']['AcquirerId'],
'MerchantReference' => $params['Request']['MerchantReference'],
'Timestamp' => $Timestamp,
'MinutesToExpiration' => $MinutesToExpiration
);
}
else {
$piraeus_ticket_response = array(
'Status' => 'Failed',
'MerchantReference' => $params['Request']['MerchantReference'],
'Thrown' => $ResultDescription
);
}
}
@vasileios-tsakalis Ευχαριστώ για την άμεση απάντηση, έχω καινούργιο error Argument 3 passed to Artisaninweb\SoapWrapper\Client::SoapCall() must be of the type array or null, string given, called in ***/vendor/artisaninweb/laravel-soap/src/Artisaninweb/SoapWrapper/SoapWrapper.php on line 137, αφαιρώντας τις γραμμές
'http://piraeusbank.gr/paycenter/redirection', 'http://piraeusbank.gr/paycenter/redirection/IssueNewTicket'
δεν βγάζει το error και παίρνω απάντηση το : {"Status":"Failed","MerchantReference":"*****","Thrown":"[SRID: ****] Invalid IP address."} που νομίζω είναι λογικό μιας και δεν είμαι στην IP που περιμένει η τράπεζα.
Ευχαριστώ και πάλι μέσα από καραντίνα :)
@kastony Παρακαλώ φίλε μου. Ενδεχομένως οι γραμμές να μην είναι απαραίτητες πλέον λόγω ότι το πακέτο έχει καινούργια έκδοση, εγώ χρησιμοποιώ μια παλαιότερη από το 2018.
Σωστά αναφέρεις το σφάλμα με την IP, το request πρέπει να πραγματοποιηθεί μέσω της IP που έχεις δηλώσει, δηλαδή σε production mode μέσω του διακομιστή. Δυστυχώς η Πειραιώς δεν έχει ένα είδους sandbox ώστε να κάνουμε τις δοκιμές μας εμείς οι developer's. Εύχομαι καλή δύναμη και να είμαστε όλοι υγιείς. Ότι χρειαστείς μην διστάσεις να μου στείλεις:)