Skip to content

Instantly share code, notes, and snippets.

@jagroop
Created October 3, 2019 11:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jagroop/ad5cc4b9885755621e3dff06bc267b5f to your computer and use it in GitHub Desktop.
Save jagroop/ad5cc4b9885755621e3dff06bc267b5f to your computer and use it in GitHub Desktop.
<?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