Created
April 1, 2015 08:44
-
-
Save akalongman/56484900eaf19b18cfbd to your computer and use it in GitHub Desktop.
PHP soap client example
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
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; |
Server was unable to process request. ---> The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters.
i am having above error. any idea what is the wrong. if you want i can send you code also
Can you please share how to update a value over soap and php?
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
Hello,
Culd you tell how can I send back a xml to wsdl?
I used this "PHP soap client example" above to get records from a wsdl and work well, but now I have to send back to ws a xml to mark each record as processed in order to avoid a new receivings from the same record.
The documentation of wsdl says:
method: AlterarSituacaoControleFluxoAbastecimentoAuth
request parameters:
user: string
password: string
xml : xml
The xml has to be like this:

How can I send this? Could you post a simple example, please?
Thanks in advance.