• Publicidad

Construir SOAP con SOAP::LITE

¿Apenas comienzas con Perl? En este foro podrás encontrar y hacer preguntas básicas de Perl con respuestas aptas a tu nivel.

Construir SOAP con SOAP::LITE

Notapor coltx » 2016-10-06 14:36 @650

Hola, estoy teniendo el siguiente problema. El script a continuación genera un SOAP que no es el correcto para el WS que estoy tratando de consumir, ¿cómo podría crear y enviar el mensaje SOAP que necesita el WS?

Mi script es el siguiente:

Sintáxis: [ Descargar ] [ Ocultar ]
Using perl Syntax Highlighting
  1. #!/usr/bin/perl
  2. use SOAP::Lite +trace => 'all';
  3.  
  4.  
  5.  
  6. sub SOAP::Transport::HTTP::Client::get_basic_credentials {
  7.   return 'usuario' => 'password';
  8. }
  9.  
  10.  
  11. my $service
  12.  = SOAP::Lite
  13.     ->uri('http://ws.prueba.com/')
  14.     ->proxy('http://120.92.221.114:8080/prueba/ws/Movimientos?wsdl');
  15.  
  16.  
  17. # calling the insert function
  18. my $method = SOAP::Data->name('Consultar')
  19.     ->attr({xmlns => 'http://ws.prueba.com/'});
  20.  
  21. # create a new incident with the following short_description and category
  22. my @params = ( SOAP::Data->name(cliente => '123') );
  23. push(@params, SOAP::Data->name(fechaDesde => '2016-01-01') );
  24. push(@params, SOAP::Data->name(fechaHasta => '2016-09-31') );
  25. push(@params, SOAP::Data->name(tipo => 'INICIAL') );
  26.  
  27. my $result = $service->call($method => @params);
  28.  
  29. # print any SOAP faults that get returned
  30. print_fault($result);
  31. # print the SOAP response that get return
  32. print_result($result);
  33.  
  34. # convenient subroutine for printing all results
  35. sub print_result {
  36.   my ($result) = @_;
  37.  
  38.   if ($result->body && $result->body->{'insertResponse'}) {
  39.     my %keyHash = %{ $result->body->{'insertResponse'} };
  40.     foreach my $k (keys %keyHash) {
  41.         print "name=$k   value=$keyHash{$k}\n";
  42.     }
  43.   }
  44. }
  45.  
  46. # convenient subroutine for printing all SOAP faults
  47. sub print_fault {
  48.   my ($result) = @_;
  49.  
  50.   if ($result->fault) {
  51.     print "faultcode=" . $result->fault->{'faultcode'} . "\n";
  52.     print "faultstring=" . $result->fault->{'faultstring'} . "\n";
  53.     print "detail=" . $result->fault->{'detail'} . "\n";
  54.   }
  55. }
Coloreado en 0.006 segundos, usando GeSHi 1.0.8.4

Lo anterior crea el siguiente mensaje:
Sintáxis: [ Descargar ] [ Ocultar ]
Using xml Syntax Highlighting
  1. <soap:Envelope
  2.         soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
  3.         xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
  4.         xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
  5.         xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  6.         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  7.  
  8.         <soap:Body>
  9.                 <Consultar xmlns="http://ws.prueba.com/">
  10.                         <cliente xsi:type="xsd:int">123</cliente>
  11.                         <fechaDesde xsi:type="xsd:date">2016-01-01</fechaDesde>
  12.                         <fechaHasta xsi:type="xsd:date">2016-09-31</fechaHasta>
  13.                         <tipo xsi:type="xsd:string">INICIAL</tipoFecha>
  14.                 </Consultar>
  15.         </soap:Body>
  16. </soap:Envelope>
Coloreado en 0.001 segundos, usando GeSHi 1.0.8.4

Pero necesito que se genere el siguiente mensaje:
Sintáxis: [ Descargar ] [ Ocultar ]
Using xml Syntax Highlighting
  1. <soap:Envelope
  2.    soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
  3.    xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
  4.    xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
  5.    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  6.    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  7.    xmlns:ws="http://ws.prueba.com/">
  8.    <soap:Body>
  9.       <ws:Consultar>
  10.          <cliente xsi:type="xsd:int">123</cliente>
  11.                  <fechaDesde xsi:type="xsd:date">2016-01-01</fechaDesde>
  12.                  <fechaHasta xsi:type="xsd:date">2016-09-31</fechaHasta>
  13.                  <tipo xsi:type="xsd:string">INICIAL</tipoFecha>
  14.       </ws:Consultar>
  15.    </soap:Body>
  16. </soap:Envelope>
Coloreado en 0.000 segundos, usando GeSHi 1.0.8.4


¿Cómo puedo generar este último mensaje?
coltx
Perlero nuevo
Perlero nuevo
 
Mensajes: 79
Registrado: 2011-09-16 08:01 @376

Publicidad

Re: Construir SOAP con SOAP::LITE

Notapor coltx » 2016-10-23 17:57 @789

Amigos, ¿alguna idea?
coltx
Perlero nuevo
Perlero nuevo
 
Mensajes: 79
Registrado: 2011-09-16 08:01 @376


Volver a Básico

¿Quién está conectado?

Usuarios navegando por este Foro: No hay usuarios registrados visitando el Foro y 5 invitados