Skip to content

Instantly share code, notes, and snippets.

@akalongman
Created April 1, 2015 08:44
Show Gist options
  • Star 40 You must be signed in to star a gist
  • Fork 16 You must be signed in to fork a gist
  • Save akalongman/56484900eaf19b18cfbd to your computer and use it in GitHub Desktop.
Save akalongman/56484900eaf19b18cfbd to your computer and use it in GitHub Desktop.
PHP soap client example
ini_set('soap.wsdl_cache_enabled', 0);
ini_set('soap.wsdl_cache_ttl', 900);
ini_set('default_socket_timeout', 15);
$params = array('param1'=>$param1);
$wsdl = 'http://service_url/method?WSDL';
$options = array(
'uri'=>'http://schemas.xmlsoap.org/soap/envelope/',
'style'=>SOAP_RPC,
'use'=>SOAP_ENCODED,
'soap_version'=>SOAP_1_1,
'cache_wsdl'=>WSDL_CACHE_NONE,
'connection_timeout'=>15,
'trace'=>true,
'encoding'=>'UTF-8',
'exceptions'=>true,
);
try {
$soap = new SoapClient($wsdl, $options);
$data = $soap->method($params);
}
catch(Exception $e) {
die($e->getMessage());
}
var_dump($data);
die;
@vladmir224
Copy link

Voici un exemple avec php

try {

         $urlexemple = 'http://webservices.oorsprong.org/websamples.countryinfo/CountryInfoService.wso?WSDL';
        $arrContextOptions=array("ssl"=>array( "verify_peer"=>false, "verify_peer_name"=>false,'crypto_method' => STREAM_CRYPTO_METHOD_TLS_CLIENT));
        $options = array('soap_version'=>SOAP_1_2,'exceptions'=>true,'trace'=>1,'cache_wsdl'=>WSDL_CACHE_NONE,'stream_context' => stream_context_create($arrContextOptions));
        $soapclient = new SoapClient($urlEdg, $options);
        // parametre
      $paramexemple=array('sCountryISOCode'=>$request->devise);
      $response =$soapclient->FullCountryInfo($paramexemple);
        $array = json_decode(json_encode($response), true);

        return $array;

    } catch (Throwable $e) {
        return $e->getMessage();
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment