Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require 'lib/nusoap.php';
- // SOAP login credentials
- $username = 'rrigor';
- $secret = '1qazxsw2';
- // URLS
- $calidad = "https://201.134.132.139:7443/ValidaReferenciasTelefonicasWeb/services/ConfirmacionReferencia?wsdl";
- $produccion = "http://credito.infonavit.org.mx/ValidaReferenciasTelefonicasWeb/sca/Consultar/wsdl/Consultar_ConsultarHttp_Service.wsdl";
- // Definimos si usamos el URL de calidad o el de producción
- $url = $calidad;
- $client = new nusoap_client($url,'wsdl');
- $client->soap_defencoding = 'UTF-8';
- $client->forceEndpoint ="https://201.134.132.139:7443/ValidaReferenciasTelefonicasWeb/services/ConfirmacionReferencia";
- // Agregamos namespaces extra para las definiciones necesarias
- $namespaces = array('cal' => 'http://callback.soc.servicios.infonavit.org.mx');
- $client->namespaces = array_merge($client->namespaces,$namespaces);
- $err = $client->getError();
- if ($err) {
- // Display the error
- echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
- // At this point, you know the call that follows will fail
- }
- $a = array(
- 'nss' => '92018412673',
- 'nombre' => 'JUAN SOLANO VAZQUEZ JUAN JOSE',
- 'despacho' => '2001',
- 'referencia' => array(
- 'accion' => 'C',
- 'tipo' => 5,
- 'contacto' => 'SOLANO VAZQUEZ MARIA FRANCISCA',
- 'telefono' => '5565947860',
- 'situacion' => '1',
- 'clasificacion' => '102',
- 'fechallamada' => '20140904080200',
- 'duracion' => 1,
- 'personaconfirma' => array(
- 'parentesco' => 1034,
- 'nombre' => 'ROSENDO PEREZ',
- 'edad' => 52,
- 'telefonoadicional' => '5523456781',
- 'observacion' => 'Campo libre para datos'
- )
- )
- );
- $namespace = "http://callback.soc.servicios.infonavit.org.mx/";
- $result = $client->call('Confirmacion',$client->serialize_val($a,'cal:confirmacion',false,false,false,false,'literal'),NULL,NULL, get_header($username,$secret));
- if ($client->fault) {
- echo '<h2>Fault</h2><pre>';
- print_r($result);
- echo '</pre>';
- } else {
- // Check for errors
- $err = $client->getError();
- if ($err) {
- // Display the error
- echo '<h2>Error</h2><pre>' . $err . '</pre>';
- } else {
- // Display the result
- echo '<h2>Result</h2><pre>';
- print_r($result);
- echo '</pre>';
- }
- }
- // Display the request and response
- echo '<h2>Request</h2>';
- echo $client->request;
- echo '<h2>Response</h2>';
- echo $client->response;
- // Display the debug messages
- echo '<h2>Debug</h2>';
- //echo nl2br($client->debug_str);
- function get_header($username, $secret)
- {
- // Create a unique identifier, or nonce.
- // This example is used for simplicity in demonstration. Use a method
- // that guarantees uniqueness in a production environment.
- $nonce = md5(rand());
- $created = date("Y-m-d\TH:i:s\Z");
- $combo_string = $nonce . $created . $secret;
- // The sha1 command is not available in all versions of PHP.
- // If your version of PHP does not support this command, use
- //openssl directly with the command:
- // echo -n <string> | openssl dgst -sha1
- $sha1_string = sha1($combo_string);
- $password = base64_encode($sha1_string);
- $headers ='<wsse:Security SOAP-ENV:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"><wsse:UsernameToken wsu:Id="UsernameToken-407BC42C256EE81B31141101307204433"><wsse:Username>'.$username.'</wsse:Username><wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">'.$secret.'</wsse:Password></wsse:UsernameToken></wsse:Security>';
- return $headers;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement