Created
October 3, 2019 11:00
-
-
Save jagroop/ad5cc4b9885755621e3dff06bc267b5f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Helpers; | |
class SoapClientHelper { | |
public static function request($name, $params = []) | |
{ | |
$wsdl = config('wsdl.'.$name.'.endpoint'); | |
$method = config('wsdl.'.$name.'.method_name'); | |
$user = config('b2b_wsdl.credentials.user'); | |
$password = config('b2b_wsdl.credentials.password'); | |
$opts = array( | |
'ssl' => array( | |
'verify_peer' => false, | |
'verify_peer_name' => false, | |
'allow_self_signed' => true | |
) | |
); | |
$context = stream_context_create($opts); | |
$client = null; | |
try { | |
$client = new \SoapClient($wsdl, array( | |
'stream_context' => $context, 'trace' => true, | |
'login' => $user, 'password' => $password) | |
); | |
$response = $client->{$method}($params); | |
return $response; | |
} catch(\Exception $e) { | |
return false; | |
} | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment