Skip to content

Instantly share code, notes, and snippets.

@loru88
Created November 28, 2017 13:55
Show Gist options
  • Save loru88/7b67e23ff6df77b2bc56f550d164a198 to your computer and use it in GitHub Desktop.
Save loru88/7b67e23ff6df77b2bc56f550d164a198 to your computer and use it in GitHub Desktop.
SOAP in PHP
<?php
/**
* http://php.net/manual/en/soapclient.soapclient.php
*
**/
$options = array();
// general option
$options['encoding'] = 'UTF-8';
$options['soap_version'] = SOAP_1_1;
$options['cache_wsdl'] = WSDL_CACHE_NONE;
$options['compression'] = SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP;
// for debugging
$options['trace'] = true;
$options['exceptions'] = true;
// basic authentication
$options['login'] = '{{ domain\username }}';
$options['password'] = '{{ password }}';
// SSL certificate configuration, http://php.net/manual/en/context.ssl.php
$options['stream_context'] = stream_context_create([
'ssl' => [
'verify_peer'=> true,
'verify_peer_name' => false,
'allow_self_signed' => true,
'local_cert' => '{{ public key pem path }}',
'local_pk' => '{{ private key pem path }}',
'passphrase' => '{{ cert password }}'
]
]);
//create the client
$client = new SoapClient('{{ path to WSDL }}', $options);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment