Advertisement
Guest User

Untitled

a guest
Sep 18th, 2014
300
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.67 KB | None | 0 0
  1. <?php
  2. require 'lib/nusoap.php';
  3. // SOAP login credentials
  4. $username = 'rrigor';
  5. $secret = '1qazxsw2';
  6.  
  7. // URLS
  8. $calidad = "https://201.134.132.139:7443/ValidaReferenciasTelefonicasWeb/services/ConfirmacionReferencia?wsdl";
  9. $produccion = "http://credito.infonavit.org.mx/ValidaReferenciasTelefonicasWeb/sca/Consultar/wsdl/Consultar_ConsultarHttp_Service.wsdl";
  10. // Definimos si usamos el URL de calidad o el de producción
  11. $url = $calidad;
  12.  
  13. $client = new nusoap_client($url,'wsdl');
  14. $client->soap_defencoding = 'UTF-8';
  15. $client->forceEndpoint ="https://201.134.132.139:7443/ValidaReferenciasTelefonicasWeb/services/ConfirmacionReferencia";
  16.  
  17. // Agregamos namespaces extra para las definiciones necesarias
  18. $namespaces = array('cal' => 'http://callback.soc.servicios.infonavit.org.mx');
  19. $client->namespaces = array_merge($client->namespaces,$namespaces);
  20.  
  21.  
  22. $err = $client->getError();
  23. if ($err) {
  24. // Display the error
  25. echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
  26. // At this point, you know the call that follows will fail
  27. }
  28. $a = array(
  29. 'nss' => '92018412673',
  30. 'nombre' => 'JUAN SOLANO VAZQUEZ JUAN JOSE',
  31. 'despacho' => '2001',
  32. 'referencia' => array(
  33. 'accion' => 'C',
  34. 'tipo' => 5,
  35. 'contacto' => 'SOLANO VAZQUEZ MARIA FRANCISCA',
  36. 'telefono' => '5565947860',
  37. 'situacion' => '1',
  38. 'clasificacion' => '102',
  39. 'fechallamada' => '20140904080200',
  40. 'duracion' => 1,
  41. 'personaconfirma' => array(
  42. 'parentesco' => 1034,
  43. 'nombre' => 'ROSENDO PEREZ',
  44. 'edad' => 52,
  45. 'telefonoadicional' => '5523456781',
  46. 'observacion' => 'Campo libre para datos'
  47. )
  48. )
  49. );
  50.  
  51. $namespace = "http://callback.soc.servicios.infonavit.org.mx/";
  52. $result = $client->call('Confirmacion',$client->serialize_val($a,'cal:confirmacion',false,false,false,false,'literal'),NULL,NULL, get_header($username,$secret));
  53.  
  54. if ($client->fault) {
  55. echo '<h2>Fault</h2><pre>';
  56. print_r($result);
  57. echo '</pre>';
  58. } else {
  59. // Check for errors
  60. $err = $client->getError();
  61. if ($err) {
  62. // Display the error
  63. echo '<h2>Error</h2><pre>' . $err . '</pre>';
  64. } else {
  65. // Display the result
  66. echo '<h2>Result</h2><pre>';
  67. print_r($result);
  68. echo '</pre>';
  69. }
  70. }
  71. // Display the request and response
  72. echo '<h2>Request</h2>';
  73. echo $client->request;
  74. echo '<h2>Response</h2>';
  75. echo $client->response;
  76. // Display the debug messages
  77. echo '<h2>Debug</h2>';
  78. //echo nl2br($client->debug_str);
  79.  
  80.  
  81. function get_header($username, $secret)
  82. {
  83. // Create a unique identifier, or nonce.
  84. // This example is used for simplicity in demonstration. Use a method
  85. // that guarantees uniqueness in a production environment.
  86. $nonce = md5(rand());
  87. $created = date("Y-m-d\TH:i:s\Z");
  88. $combo_string = $nonce . $created . $secret;
  89.  
  90. // The sha1 command is not available in all versions of PHP.
  91. // If your version of PHP does not support this command, use
  92. //openssl directly with the command:
  93. // echo -n <string> | openssl dgst -sha1
  94. $sha1_string = sha1($combo_string);
  95. $password = base64_encode($sha1_string);
  96.  
  97.  
  98. $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>';
  99.  
  100. return $headers;
  101. }
  102.  
  103. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement