This is the curl code
if($this->request->is('ajax')){
$datos = $this->request->data['curp'];
$this->response->disableCache();
$this->autoRender = false;
clearstatcache();
date_default_timezone_set('America/Mexico_City');
$fecha_actual = date('Y-m-d\TH:i:s'); // substr( date('c'),0,19);
$arrayModelo = array();
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "http://url/wsConsultaP?wsdl=",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:typ=\"urn:wsConsultaCP/types\">\r\n <soapenv:Header/>\r\n <soapenv:Body>\r\n <typ:consultaP>\r\n <String_1>".$datos."</String_1>\r\n </typ:consultaP>\r\n </soapenv:Body>\r\n</soapenv:Envelope>",
CURLOPT_HTTPHEADER => array(
"cache-control: no-cache",
"content-type: text/xml",
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
//echo "cURL Error #:" . $err;
$response = "cURL Error #:" . $err;
$this->response->body($response);
$this->response->type('json');
return $this->response;
} else {
//print_r(htmlentities($response));
$xml = simplexml_load_string($response);
$ns = $xml->getNamespaces(true);
$xml->registerXPathNamespace('e', $ns['env']);
$xml->registerXPathNamespace('n', $ns['ns0']);
foreach ($xml->xpath('//n:consultaxCURPResponse') as $nodo)
{
array_push($arrayModelo, $nodo[0]->result);
}
$this->response->body(json_encode($arrayModelo[0]));
$this->response->type('json');
return $this->response;
}
}