Ver Mensaje Individual
  #30 (permalink)  
Antiguo 04/08/2010, 17:32
fran86
 
Fecha de Ingreso: agosto-2002
Ubicación: Colón - Entre Rios - Argentina
Mensajes: 647
Antigüedad: 21 años, 8 meses
Puntos: 8
Respuesta: Ayuda traducir consumo webservices desde .net a php

Mira, empece a hacer proebas con wse-php, logro que me tire el listado de funciones correctamente, claro que cuando intento llamar getBankList(), devuelve error "SOAP header Security was not understood." porque no tengo como probar ws security. Eso deberias hacerlo vos con tus .pem.

Por cierto, en que parte de tu codigo .net le indicas a soap que use wss?

Código PHP:
Ver original
  1. require('wse-php/soap-wsse.php');
  2.  
  3. //comente todas las lineas que tendrias que investigar
  4. //define('PRIVATE_KEY', 'C:\TEMP\pk-amazon-private-key.pem');
  5. //define('CERT_FILE', 'C:\temp\cert-amazon-cert.pem');
  6.  
  7. class mySoap extends SoapClient {
  8.  
  9.     function __doRequest($request, $location, $saction, $version) {
  10.         $doc = new DOMDocument('1.0');
  11.         $doc->loadXML($request);
  12.  
  13.         $objWSSE = new WSSESoap($doc);
  14.        
  15.         $objWSSE->addTimestamp();
  16.  
  17.         // comente todas las lineas que tendrias que investigar
  18.  
  19.         /* create new XMLSec Key using RSA SHA-1 and type is private key */
  20.         //$objKey = new XMLSecurityKey(XMLSecurityKey::RSA_SHA1, array('type'=>'private'));
  21.  
  22.         /* load the private key from file - last arg is bool if key in file (TRUE) or is string (FALSE) */
  23.         //$objKey->loadKey(PRIVATE_KEY, TRUE);
  24.  
  25.         /* Sign the message - also signs appropraite WS-Security items */
  26.         //$objWSSE->signSoapDoc($objKey);
  27.  
  28.         /* Add certificate (BinarySecurityToken) to the message and attach pointer to Signature */
  29.         //$token = $objWSSE->addBinaryToken(file_get_contents(CERT_FILE));
  30.         //$objWSSE->attachTokentoSig($token);
  31.  
  32.         return parent::__doRequest($objWSSE->saveXML(), $location, $saction, $version);
  33.     }
  34. }
  35.  
  36. class instances {
  37.     public $instancesSet = NULL;
  38. }
  39.  
  40. $wsdl = 'https://desarrollo.pse.com.co/PSEWebServices/MainServices.asmx?wsdl';
  41.  
  42. try {
  43.     $sClient = new mySoap($wsdl, array('trace'=>1));
  44.     /* Force location path - MUST INCLUDE trailing slash
  45.     BUG in ext/soap that does not automatically add / if URL does not contain path cause POST header to be invalid */
  46.     //$sClient->location = 'https://ec2.amazonaws.com/';
  47.  
  48.     //$sClient->getBankList();
  49.  
  50.     //$objInstances = new instances();
  51.     //$test = $sClient->DescribeInstances($objInstances);
  52.  
  53.     var_dump($sClient->__getFunctions()); // esto te tira la lista de metodos ok
  54.  
  55.     var_dump($sClient->getBankList('001')); // esto me da SOAP header Security was not understood.;
  56.     // obvio porque los certificados no estan configurados,
  57.     // deberias intentar basandote en los ejemplos de la direccion que te pase.
  58.  
  59. } catch (SoapFault $e) {
  60.     var_dump($e);
  61. }