I am using below code for SOAP request.
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://example.com?WSDL",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS =>"<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ns1=\"http://Xyz.Abc\" xmlns:ns2=\"http://tempuri.org/\"><SOAP-ENV:Body><ns2:GetStatus><ns1:ReferenceNo>12345</ns1:ReferenceNo></ns2:GetStatus></SOAP-ENV:Body></SOAP-ENV:Envelope>",
CURLOPT_HTTPHEADER => array(
"Content-Type: text/xml"
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
Response:
Getting below response when I set header('Content-type: application/xml'); in php script which is correct.
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsa="http://www.w3.org/2005/08/addressing">
<env:Header>...</env:Header>
<env:Body>
<GetStatusResponse xmlns:s1="http://Xyz.Abc" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://tempuri.org/" xmlns="http://tempuri.org/">
<s1:StatusResponse>
<s1:Test ResponseCode="INPROGRESS" ResponseMessage="Reference no. 12345"/>
</s1:StatusResponse>
</GetStatusResponse>
</env:Body>
</env:Envelope>
How can I extract Body values from the response without just printing on browser?
Here is what I tried
Remove xml header and parse response string by simplexml_load_string method.
$xml = simplexml_load_string($response);
echo $xml;
$json = json_encode($response);
$arr = json_decode($json,true);
print_r($arr);
I also tried with SimpleXMLElement, but, it's printing empty response:
$test = new SimpleXMLElement($response);
echo $test;
But, it's printing empty result.
SimpleXML is an object. It isn't the full XML string as you might think. Try this.
//Cast to string to force simpleXml to convert into a string
$xmlString = $xml->asXML();
echo $xmlString . "\n";
I'm pretty sure you can't do this because $response is XML. Trying to json_encode it doesn't make sense.
$json = json_encode($response);
I did this:
<?php
$x = '<?xml version="1.0" ?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsa="http://www.w3.org/2005/08/addressing">
<env:Header>...</env:Header>
<env:Body>
<GetStatusResponse xmlns:s1="http://Xyz.Abc" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://tempuri.org/" xmlns="http://tempuri.org/">
<s1:StatusResponse>
<s1:Test ResponseCode="INPROGRESS" ResponseMessage="Reference no. 12345"/>
</s1:StatusResponse>
</GetStatusResponse>
</env:Body>
</env:Envelope>';
$xml = simplexml_load_string($x);
echo $xml->asXml();
echo "\n";
And I get this output:
<?xml version="1.0"?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsa="http://www.w3.org/2005/08/addressing">
<env:Header>...</env:Header>
<env:Body>
<GetStatusResponse xmlns:s1="http://Xyz.Abc" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://tempuri.org/" xmlns="http://tempuri.org/">
<s1:StatusResponse>
<s1:Test ResponseCode="INPROGRESS" ResponseMessage="Reference no. 12345"/>
</s1:StatusResponse>
</GetStatusResponse>
</env:Body>
</env:Envelope>
This explains how to specify namespaces.
https://www.php.net/manual/en/simplexmlelement.attributes.php
$xml->registerXPathNamespace('e', 'http://schemas.xmlsoap.org/soap/envelope/');
$xml->registerXPathNamespace('s', 'http://Xyz.Abc');
$result = $xml->xpath('//s:Test');
$response = $result[0]->attributes();
echo "Response Code = " . $response['ResponseCode'] . "\n";
echo "Response Message = " . $response['ResponseMessage'] . "\n";
Related
I successfully get response from soap webservice using php curl. I would like to know how can I parse the curl response so that I got each value separately in other to save into database.
my codes:
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "http://xxxxxx/WSAutorizaciones/WSAutorizacionLaboratorio.asmx?WSDL",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS =>
'<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<AuthenticationHeader xmlns="https://arssenasa.gob.do/">
<Cedula>001-0946651-5</Cedula>
<Password>xxxxxxx</Password>
<Proveedo>12077</Proveedo>
</AuthenticationHeader>
</soap:Header>
<soap:Body>
<ConsultarAfiliado xmlns="https://arssenasa.gob.do/">
<TipoDocumento>2</TipoDocumento>
<NumDocumento>021827151</NumDocumento>
</ConsultarAfiliado>
</soap:Body>
</soap:Envelope>',
CURLOPT_HTTPHEADER => array("content-type: text/xml"),
))
;
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
The result is displayed like this:
8013-0000655-6021827151MARGARET ADIRASANTANA LORENZO DE CABRAL08CONTRIBUTIVO22/11/197346FEMENINO08
the soap resonse is like this:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<ConsultarAfiliadoResponse xmlns="https://arssenasa.gob.do/">
<ConsultarAfiliadoResult>
<Contrato>8</Contrato>
<Cedula>013-0000655-6</Cedula>
<Nss>021827151</Nss>
<Nombres>MARGARET ADIRA</Nombres>
<Apellidos>SANTANA LORENZO DE CABRAL</Apellidos>
<IdEstado>0</IdEstado>
<CodigoFamiliar>8</CodigoFamiliar>
<IdRegimen xsi:nil="true" />
<Regimen>CONTRIBUTIVO</Regimen>
<FechaNacimiento>22/11/1973</FechaNacimiento>
<Edad>46</Edad>
<Sexo>FEMENINO</Sexo>
<TipoDocumento>0</TipoDocumento>
<CodigoAfiliado>8</CodigoAfiliado>
<MensajeAfiliado />
</ConsultarAfiliadoResult>
</ConsultarAfiliadoResponse>
</soap:Body>
</soap:Envelope>
Here is a possible example of how you could go about getting the XML elements from your SOAP response (below) using SimpleXML which might be included in your PHP installation. Because I'm not sure what order of element data you need for the final output, you might need to rearrange the order of items in the output part below.
Also, in order for this to work, the $soapResponse variable in the code example needs to have no extra space before the start of the <?xml version="1.0" encoding="utf-8"?> line.
If you need to access other elements from the XML data, you should be able to do it with this pattern: $result->ConsultarAfiliadoResult->ElementNameHere.
<?php
$soapResponse = <<<XML
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<ConsultarAfiliadoResponse xmlns="https://arssenasa.gob.do/">
<ConsultarAfiliadoResult>
<Contrato>8</Contrato>
<Cedula>013-0000655-6</Cedula>
<Nss>021827151</Nss>
<Nombres>MARGARET ADIRA</Nombres>
<Apellidos>SANTANA LORENZO DE CABRAL</Apellidos>
<IdEstado>0</IdEstado>
<CodigoFamiliar>8</CodigoFamiliar>
<IdRegimen xsi:nil="true" />
<Regimen>CONTRIBUTIVO</Regimen>
<FechaNacimiento>22/11/1973</FechaNacimiento>
<Edad>46</Edad>
<Sexo>FEMENINO</Sexo>
<TipoDocumento>0</TipoDocumento>
<CodigoAfiliado>8</CodigoAfiliado>
<MensajeAfiliado />
</ConsultarAfiliadoResult>
</ConsultarAfiliadoResponse>
</soap:Body>
</soap:Envelope>
XML;
// Remove <soap></soap> related tag information to get plain XML content
$xmlContent = preg_replace('/<soap:.*?>\n/', '', $soapResponse);
$xmlContent = preg_replace('/<\/soap:.*?>\n?/', '', $xmlContent);
// Note: there is an error with the xsi:nil="true" part, but that can be
// suppressed with the following line. If you need to deal with this error,
// more info here: https://www.php.net/manual/en/simplexml.examples-errors.php
libxml_use_internal_errors(true);
$result = new SimpleXMLElement($xmlContent);
// Print out results
printf(
"%s%s%s%s%s%s%s%s%s%s%s%s",
$result->ConsultarAfiliadoResult->Cedula,
$result->ConsultarAfiliadoResult->Nss,
$result->ConsultarAfiliadoResult->Nombres,
$result->ConsultarAfiliadoResult->Apellidos,
$result->ConsultarAfiliadoResult->IdEstado,
$result->ConsultarAfiliadoResult->CodigoFamiliar,
$result->ConsultarAfiliadoResult->Regimen,
$result->ConsultarAfiliadoResult->FechaNacimiento,
$result->ConsultarAfiliadoResult->Edad,
$result->ConsultarAfiliadoResult->Sexo,
$result->ConsultarAfiliadoResult->TipoDocumento,
$result->ConsultarAfiliadoResult->CodigoAfiliado
);
?>
Output:
$ php q22.php
013-0000655-6021827151MARGARET ADIRASANTANA LORENZO DE CABRAL08CONTRIBUTIVO22/11/197346FEMENINO08
After almost a journey of research I finally get the correct way to do it :
//The follow-up of my posting codes
.
.
.
$response = curl_exec($curl);
$response = preg_replace("/(<\/?)(\w+):([^>]*>)/", "$1$2$3", $response);
$xml = new SimpleXMLElement($response);
$body = $xml->xpath('//soapBody ')[0];
$array = json_decode(json_encode((array)$body), TRUE);
// in the case I want to grab only one data
//echo $array['ConsultarAfiliadoResponse']['ConsultarAfiliadoResult']['Cedula'];
// to display all data in the array
function dispaly_array_recursive($array_rec){
if($array_rec){
foreach($array_rec as $value){
if(is_array($value)){
dispaly_array_recursive($value);
}else{
echo $value.'<br>';
}
}
}
}
dispaly_array_recursive($array);
No more problem to save into database now
How can I make Soap request using Curl php by using below soap format and url? I have tried avaliable solutions online and none of them worked out.
$soap_request = '<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:alisonwsdl" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<soap:Header>
<credentials>
<alisonOrgId>9ReXlYlpOThe24AWisE</alisonOrgId>
<alisonOrgKey>C2owrOtRegikaroXaji</alisonOrgKey>
</credentials>
</soap:Header>
<SOAP-ENV:Body>
<q1:login xmlns:q1="urn:alisonwsdl">
<email xsi:type="xsd:string">email</email>
<firstname xsi:type="xsd:string">fname</firstname>
<lastname xsi:type="xsd:string">lname</lastname>
<city xsi:type="xsd:string">city</city>
<country xsi:type="xsd:string">country</country>
<external_id xsi:type="xsd:string"></external_id>
</q1:login>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>';
Url
https://alison.com/api/service.php?wsdl
Assuming you already have php_soap extension installed, you can access the SOAP API like this:
<?php
$client = new SoapClient('https://alison.com/api/service.php?wsdl', array(
'stream_context' => stream_context_create(array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
))
));
You might want to define the header for authentication as well
$auth = array(
'alisonOrgId' => '9ReXlYlpOThe24AWisE',
'alisonOrgKey' => 'C2owrOtRegikaroXaji'
);
$header = new SoapHeader('https://alison.com/api/service.php?wsdl', 'credentials', $auth, false);
$client->__setSoapHeaders($header);
Then you can get the list of functions available
// Get function list
$functions = $client->__getFunctions ();
echo "<pre>";
var_dump ($functions);
echo "</pre>";
die;
Or call a function right away, like this:
// Run the function
$obj = $client->__soapCall("emailExists", array(
"email" => "test#email.com"
));
echo "<pre>";
var_dump ($obj);
echo "</pre>";
die;
After struggling for a week I was able to find something in this tutorial here on youtube https://www.youtube.com/watch?v=6V_myufS89A and I was able to send requests to the API successifuly, first read my xml format above before continuing with my solution
$options = array('trace'=> true, "exception" => 0);
$client = new \SoapClient('your url to wsdl',$options);
//if you have Authorization parameters in your xml like mine above use SoapVar and SoapHeader as me below
$params = new \stdClass();
$params->alisonOrgId = 'value here';
$params->alisonOrgKey = 'value here';
$authentication_parameters = new \SoapVar($params,SOAP_ENC_OBJECT);
$header = new \SoapHeader('your url to wsdl','credentials',$authentication_parameters);
$client->__setSoapHeaders(array($header));
print_r($client->__soapCall("Function here",'Function parameter here or left it as null if has no parameter'));
//or call your function by
print_r($client->yourFunction($function_parameters));
}
Hope this will help someone out there struggling with soap requests that contains authentication informations
I'm using simplexml to parse a curl response. I am correctly getting the response but having trouble getting certain attributes from the response...
//Sending my data to web service
$curl = curl_init();
curl_setopt_array($curl, Array(
CURLOPT_URL => 'https://webservice.tld',
CURLOPT_POST => count($xml->asXML()),
CURLOPT_POSTFIELDS => $xml->asXML(),
CURLOPT_TIMEOUT => 120,
CURLOPT_CONNECTTIMEOUT => 30,
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_ENCODING => 'UTF-8'
));
//Get the response
$reply = curl_exec($curl);
$responseData = simplexml_load_string($reply);
//Print the response
print_r($responseData);
This then correctly shows the xml response as:
<?xml version="1.0" encoding="utf-16"?>
<cXML payloadID="test" xml:lang="en" timestamp="2017-09-13T09:49:58.1219095+01:00">
<Response>
<Status code="500" text="Price does not match current pricelist" />
</Response>
</cXML>
However, i'm then trying to get just the code and text attributes from the Status but it's not outputting anything;
echo $responseData->Response->Status['code'] .' - '. $responseData->Response->Status['text'];
I have also tried;
echo $responseData->cXML->Response->Status['code'] .' - '. $responseData->cXML->Response->Status['text'];
Wondering if anyone can help?
Thanks.
You can do like this.
foreach($responseData->Response->Status->attributes() as $key => $val){
echo $key .'='. $val;
}
That is what on php documentation which you can read it here
The problem your getting (and this is why setting error messages for debugging) is...
<?php
error_reporting ( E_ALL );
ini_set ( 'display_errors', 1 );
$reply = <<< XML
<?xml version="1.0" encoding="utf-16"?>
<cXML payloadID="test" xml:lang="en" timestamp="2017-09-13T09:49:58.1219095+01:00">
<Response>
<Status code="500" text="Price does not match current pricelist" />
</Response>
</cXML>
XML;
$responseData = simplexml_load_string($reply);
gives...
Warning: simplexml_load_string(): Entity: line 1: parser error : Document labelled UTF-16 but has UTF-8 content in /home/nigel/workspace/PHPTest/TestSource/t1.php on line 15
If you change the utf-16 to utf-8, then this will parse OK and your original code should work.
<?php
error_reporting ( E_ALL );
ini_set ( 'display_errors', 1 );
$reply = <<< XML
<?xml version="1.0" encoding="utf-16"?>
<cXML payloadID="test" xml:lang="en" timestamp="2017-09-13T09:49:58.1219095+01:00">
<Response>
<Status code="500" text="Price does not match current pricelist" />
</Response>
</cXML>
XML;
$reply = preg_replace('/(<\?xml[^?]+?)utf-16/i', '$1utf-8', $reply);
$responseData = simplexml_load_string($reply);
//Print the response
echo $responseData->Response->Status['code'];
It would be ideal if whoever is generating the XML fixes this, but for now this will help solve the problem.
I am trying to call a soap server method. Everything works fine except one thing. I get a respone from the server in XML format. So far so good. But the problem is that i need to get the values of the XML and normally i do that just with a foreach and get the values i need. But this time the name of the child i need to get data from is called: 'return'. So i can not reference to that in a foreach function.
Could someone tell me how i can reach the same result but with a different way?
My answer from the server:
<soap:envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:body>
<ns2:getauthresponse xmlns:ns2="http://dpd.com/common/service/types/LoginService/2.0" xmlns:ns3="http://dpd.com/common/service/exceptions">
<return>
<delisid>thedelisid</delisid>
<customeruid>thecustomerid</customeruid>
<authtoken>theauthenticationcode</authtoken>
<depot>thedepot</depot>
</return>
</ns2:getauthresponse>
</soap:body>
</soap:envelope>
the code i would normally use to get the result:
foreach($xml->return->authtoken as $authtoken)
{
print_r($authtoken);
}
The problem is the return sign here, php keeps seeing it as the return statement.
I also made it an array using new SimpleXMLElement.
And the error i get when i run the code is:
Invalid argument supplied for foreach()
How can i get the value of authtoken?
All the code:
$xml_getAuth = '
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns="http://dpd.com/common/service/types/LoginService/2.0">
<soapenv:Header/>
<soapenv:Body>
<ns:getAuth>
<delisId>'.$delisId.'</delisId>
<password>'.$password.'</password>
<messageLanguage>'.$messageLanguage.'</messageLanguage>
</ns:getAuth>
</soapenv:Body>
<soapenv:Envelope>
';
$headers_getAuth = array(
"POST HTTP/1.1",
"Content-type: application/soap+xml; charset=\"utf-8\"",
"SOAPAction: \"http://dpd.com/common/service/LoginService/2.0/getAuth\"",
"Content-length: ".strlen($xml_getAuth)
);
$getAuth = curl_init('https://public-ws-stage.dpd.com/services/LoginService/V2_0/');
curl_setopt($getAuth, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($getAuth, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($getAuth, CURLOPT_POST, 1);
curl_setopt($getAuth, CURLOPT_HTTPHEADER, $headers_getAuth);
curl_setopt($getAuth, CURLOPT_POSTFIELDS, "$xml_getAuth");
curl_setopt($getAuth, CURLOPT_RETURNTRANSFER, 1);
$output_getAuth = curl_exec($getAuth);
//Gebruikernsaam en wachtwoord komen niet overeen
if(strpos($output_getAuth,'LOGIN_8') !== false)
{
echo "Verkeerde gebruikernsaam of wachtwoord, neem contact op met uw systeembeheerder voor meer informatie.";
exit;
}
$xml = new SimpleXMLElement($output_getAuth);
foreach($xml->return->authtoken as $authtoken)
{
print_r($authtoken);
}
Answer from the soap call:
stdClass Object ( [return] => stdClass Object ( [delisId] => delisid [customerUid] => custid [authToken] => authtoken [depot] => depot ) )
First of all, you should probably be using SoapClient instead of SimpleXML. For example:
$c = new SoapClient('https://public-ws-stage.dpd.com/services/LoginService/V2_0/?WSDL');
$res = $c->getAuth(array(
'delisId' => 'foo',
'password' => 'bar',
'messageLanguage' => 'en-us',
));
echo $res->result->authToken;
That said, using xpath solves many problems:
<?php
$response = <<<XML
<soap:envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:body>
<ns2:getauthresponse xmlns:ns2="http://dpd.com/common/service/types/LoginService/2.0" xmlns:ns3="http://dpd.com/common/service/exceptions">
<return>
<delisid>thedelisid</delisid>
<customeruid>thecustomerid</customeruid>
<authtoken>theauthenticationcode</authtoken>
<depot>thedepot</depot>
</return>
</ns2:getauthresponse>
</soap:body>
</soap:envelope>
XML;
$xml = simplexml_load_string($response);
foreach ($xml->xpath('//return') as $tmp) {
echo "authtoken = ", $tmp->authtoken, PHP_EOL;
}
I get the error message : "looks like we got no XML document" .
This is my php script :
<?php
$client = new SoapClient("http://ws-argos.cls.fr/argosDws/services/DixService?wsdl", array('trace' => 1, "exceptions" => 0));
$result = $client->getXml(array (
'username' => 'my username',
'password' => 'my password',
'platformId' => '1',
'nbPassByPtt' => 100,
'nbDaysFromNow' => 10,
'mostRecentPassages' => true
));
echo "====== REQUEST HEADERS =====" . PHP_EOL;
var_dump($client->__getLastRequestHeaders());
echo "========= REQUEST ==========" . PHP_EOL;
var_dump($client->__getLastRequest());
echo "========= RESPONSE =========" . PHP_EOL;
var_dump($result);
and this is the result of __getLastRequest() :
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="http://service.dataxmldistribution.argos.cls.fr/types">
<SOAP-ENV:Body>
<ns1:xmlRequest>
<ns1:username>my username</ns1:username>
<ns1:password>my password</ns1:password>
<ns1:platformId>1</ns1:platformId>
<ns1:nbPassByPtt>100</ns1:nbPassByPtt>
<ns1:nbDaysFromNow>10</ns1:nbDaysFromNow>
<ns1:mostRecentPassages>true</ns1:mostRecentPassages>
</ns1:xmlRequest>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
and this is how the request should look according to the documentation :
<soap:Envelope
xmlns:soap=”http://www.w3.org/2003/05/soap-envelope”
xmlns:typ=”http://service.dataxmldistribution.argos.cls.fr/types”>
<soap:Header/>
<soap:Body>
<typ:xmlRequest>
<typ:username>mturiot</typ:username>
<typ:password>qt</typ:password>
<typ:platformId>1</typ:platformId>
<typ:nbPassByPtt>2</typ:nbPassByPtt>
<typ:nbDaysFromNow>10</typ:nbDaysFromNow>
<typ:mostRecentPassages>true</typ:mostRecentPassages>
</typ:xmlRequest>
</soap:Body>
</soap:Envelope>
What am i doing wrong ? Any help is appreciated !
I came across the same problem, I turned to get solution in a different way.
It might not be the best way, but it works.
Source for the solution found here
$param = array(
'username'=>$username,
'password'=>$password,
'platformId'=>$platformId,
'nbDaysFromNow'=>20
);
$client = new SoapClient("http://ws-argos.cls.fr/argosDws/services/DixService?wsdl",
array('trace' => 1,
"exceptions" => 0,
'style'=> SOAP_DOCUMENT,
'use'=> SOAP_LITERAL));
$results = $client->getXml($param);
$results = $client->__getLastResponse();
//Handle BOM
$xml = explode("\r\n", $results);
//The resultant CDATA is at 6th tag
$response = preg_replace( '/^(\x00\x00\xFE\xFF|\xFF\xFE\x00\x00|\xFE\xFF|\xFF\xFE|\xEF\xBB\xBF)/', "", $xml[6] );
//Get the CDATA content alone
$explode1 = explode("<return>", $response);
$xmlVar = explode("</return>", $explode1[1]);
$finalXML = $xmlVar[0];
//Convert string as XML
$xmlElem = simplexml_load_string('<xml>' . $finalXML . '</xml>');
echo $xmlElem;