• Publicidad

Problema usando servicios web

Todo lo relacionado con el desarrollo Web con Perl: desde CGI hasta Mojolicious

Problema usando servicios web

Notapor Alfumao » 2011-11-29 09:20 @431

Hola de nuevo,

Estoy intentando usar los servicios web de una herramienta. En la página de dicha herramienta se proporcionan unos scripts de Perl para utilizar los servicios web, pero al ponerlos a funcionar me sale el siguiente error:

Sintáxis: [ Descargar ] [ Ocultar ]
Using text Syntax Highlighting
panic: schemas() removed in v2.00, not needed anymore
 at C:/Perl14/site/lib/XML/Compile/WSDL11.pm line 65
XML::Compile::WSDL11::schemas(XML::Compile::WSDL11=HASH(0x30ffbac)) at xml-compile.pl line 46
main::appendSchemas(XML::Compile::WSDL11=HASH(0x30ffbac), "http://www.cbs.dtu.dk/ws/common/ws_common_1_0b.xsd", "http://www.cbs.dtu.dk/ws/TMHMM/ws_tmhmm_2_0_ws0.xsd") at C:\Perlprograms\tmhmm.pl line 18
 
Coloreado en 0.000 segundos, usando GeSHi 1.0.8.4


No tengo ni idea de a lo que se refieren con "panic schemas()"...

Aquí dejo el código del programa principal para ejecutar los servicios y del programa que requiere el principal para su funcionamiento.

Script principal:
Sintáxis: [ Descargar ] [ Ocultar ]
Using perl Syntax Highlighting
  1. #!/usr/bin/perl
  2. # Description: This script runs the TMHMM 2.0 ws0 Web Service. It reads FASTA file from STDIN and produces predictions in a simple table
  3. # Author: Edita Bartaseviciute
  4. # Version: 2.0 ws0
  5. # Date: 2009-09-24
  6. # usage: perl tmhmm.pl < example.fsa
  7.  
  8. use strict;
  9. # include standard XML::Compile helper functions (used to initiate WSDL proxys)
  10.  
  11. require "xml-compile.pl";   # downloadable from the same site as this script
  12.  
  13. # create proxy to TMHMM Web Service
  14. my $tmhmm = WSDL2proxy ( 'http://www.cbs.dtu.dk/ws/TMHMM/TMHMM_2_0_ws0.wsdl' );
  15.  
  16. # append schema definitions
  17. $tmhmm = appendSchemas ( $tmhmm ,
  18.         "http://www.cbs.dtu.dk/ws/common/ws_common_1_0b.xsd" ,
  19.         "http://www.cbs.dtu.dk/ws/TMHMM/ws_tmhmm_2_0_ws0.xsd"
  20. );
  21. # create hash of operations from proxy
  22. my %ops = addOperations ( $tmhmm ) ;
  23.  
  24. # Get sequence in fasta format from STDIN
  25. my @fasta;
  26. my $entry = -1;
  27.  
  28. while (<STDIN>) {
  29.         if (/^>(.*)/) {
  30.                 my ($id , $comment) = split (" ",$1);
  31.                 $entry++;
  32.                 $fasta[$entry]->{id} = $id;
  33.                 $fasta[$entry]->{comment} = $comment if defined $comment;
  34.         } elsif (/^([A-Za-z]+)/) {
  35.                 $fasta[$entry]->{seq} .= $1;
  36.         }
  37. }
  38. # Create sequence for request
  39. my @sequence;
  40. for ( my $i = 0 ; $i < scalar ( @fasta ) ; $i ++ ) {
  41.         push @sequence , { id => $fasta[$i]->{id} , comment => $fasta[$i]->{comment} , seq => $fasta[$i]->{seq} };
  42. }
  43.  
  44. # Do the request
  45. my $response = $ops{runService}->(
  46.          parameters => {
  47.           parameters => {
  48.            sequencedata => {sequence => [@sequence]} } });
  49.  
  50. # uncomment the two following lines to inspect the structure of $response
  51. #use Data::Dumper;
  52. #print Dumper($response);  
  53.  
  54. #get job id which can be used to get the results later
  55. my $jobid;
  56.  
  57. if ( ! defined ( $response->{parameters}->{queueentry}) ) {
  58.         die "error obtaining jobid\n";
  59. } else {
  60.         $jobid = $response->{parameters}->{queueentry}->{jobid};
  61.         print STDERR "# waiting for job $jobid";
  62.         my $status = "UNKNOWN";;
  63.         # poll the queue
  64.         while ( $status =~ /ACTIVE|RUNNING|QUEUED|WAITING|PENDING|UNKNOWN/ ) {
  65.                 my $response = $ops{pollQueue}->( job => { job  => { jobid => $jobid }   }) ;
  66.                 $status = $response->{queueentry}->{queueentry}->{status};
  67.                 print STDERR  ".";
  68.         }
  69.         die "\nunexpected job status '$status'\n" unless $status eq "FINISHED";
  70.         print STDERR "\n# job has finished\n";
  71. }
  72. # when the job is done, fetch the result
  73. $response = $ops{fetchResult}->(job => { jobid => $jobid });
  74.  
  75. # uncomment the two following lines to inspect the structure of $response
  76. use Data::Dumper;
  77. print Dumper($response);
  78.  
  79. #printing the results
  80. my $method = substr ($response->{parameters}->{anndata}->{annsource}->{method}, 0, 5) . substr ($response->{parameters}->{anndata}->{annsource}->{version}, 0, 3);
  81. print "_______________________________________________________________\n";
  82. foreach my $ann (@{$response->{parameters}->{anndata}->{ann}}) {
  83.        
  84.         foreach my $annrecord (@{$ann->{annrecords}->{annrecord}}) {
  85.                 print "$ann->{sequence}->{id}\t$method\t$annrecord->{comment}\t\t$annrecord->{range}->{begin}\t$annrecord->{range}->{end}\n";
  86.                
  87.         }
  88.         print "_______________________________________________________________\n";
  89. }
Coloreado en 0.005 segundos, usando GeSHi 1.0.8.4


Programa requerido,"xml-compile.pl"

Sintáxis: [ Descargar ] [ Ocultar ]
Using perl Syntax Highlighting
  1. #!/usr/bin/perl
  2. # Description: Helper scripts used to initiate XML::Compile's proxys (WSDL+XSD)
  3. # Author: Peter Fischer Hallin
  4. # Version: NA
  5. # Date: 2008-02-13
  6.  
  7. use strict;
  8. use XML::Compile;
  9. use XML::Compile::WSDL11;
  10. use XML::Compile::Transport::SOAPHTTP;
  11. use MIME::Base64;
  12.  
  13. sub addOperations {
  14.         # builds a hash of all operations declared in the proxy
  15.         my ( $proxy , @OP )  = @_;
  16.         # @OP is an optional list of operations to compile. All will be compiled inless defined
  17.         my %ops;
  18.         my %inc;
  19.         if ( $#OP >= 0) {
  20.                 foreach (@OP) {
  21.                         $inc{$_} = 1;
  22.                 }
  23.         }
  24.         foreach my $op ($proxy->operations) {
  25.                 next if $#OP >= 0 and ! defined $inc{$op->{operation}};
  26.                 print STDERR "# compiling $op->{operation} ... \n";
  27.                 $ops{$op->{operation}} = $proxy->compileClient($op->{operation});
  28.         }
  29.         return %ops;
  30. }
  31.  
  32. sub WSDL2proxy {
  33.         # loads a WSDL and returns its proxy
  34.         my $wsdl = XML::LibXML->new->parse_file($_[0]);
  35.         my $proxy = XML::Compile::WSDL11->new($wsdl);
  36.         return $proxy;
  37. }
  38.  
  39. sub appendSchemas {
  40.         # you have to manually check which external schemas are included in
  41.         # your WSDL - this function will append them to the proxy for you
  42.         my ($proxy , @schemas) = @_;
  43.         foreach my $s (@schemas) {
  44.                 my $f = XML::LibXML->new->parse_file($s);
  45.                 $proxy->schemas->importDefinitions ($f);
  46.         }
  47.         return $proxy;
  48. }
  49.  
  50. sub wait_job {
  51.         my ($op_handle,$jobid) = @_;
  52.         my $sleep = 0;
  53.         print STDERR "# polling job $jobid\n";
  54.         my $status = "UNKNOWN";
  55.         my $response;
  56.         while ( $status !~ /FINISHED|FAILED/ ) {
  57.                 $response = $op_handle->( job => { job  => { jobid => $jobid }   }) ;
  58.                 my $new_status = $response->{queueentry}->{queueentry}->{status};
  59.                 if ( $new_status ne $status ) {
  60.                         print STDERR "# job $jobid $new_status ($response->{queueentry}->{queueentry}->{datetime})\n";
  61.                         $status = $new_status;
  62.                 }
  63.                 $sleep = 5 if $status eq "ACTIVE";
  64.                 sleep $sleep;
  65.         }
  66.         die "# ERROR: job $jobid FAILED\n" if $status ne "FINISHED";
  67. }
  68.  
  69. 1;
Coloreado en 0.003 segundos, usando GeSHi 1.0.8.4


Ojalá podaís ayudarme a desentrañar el fallo.

Gracias por adelantado
Alfumao
Perlero nuevo
Perlero nuevo
 
Mensajes: 178
Registrado: 2009-12-10 11:20 @514

Publicidad

Re: Problema usando servicios web

Notapor explorer » 2011-11-29 09:35 @441

El mensaje de error quiere decir que estás usando un módulo XML::Compile::WSDL11 demasiado "moderno", porque el código está usando una función (schemas()) que ha sido eliminado desde la versión 2.0 de ese módulo.

Ergo... si quieres usar estos programas, debes bajarte una versión de XML::Compile::WSDL11 más antigua.

Quizás en la web te indiquen qué versión debe ser.

Otra opción: hacer una versión más moderna de los programas para que usen las nuevas versiones de los módulos. (Por alguna poderosa razón tuvieron que quitar la función schemas().)
JF^D Perl programming & Raku programming. Grupo en Telegram: https://t.me/Perl_ES
Avatar de Usuario
explorer
Administrador
Administrador
 
Mensajes: 14480
Registrado: 2005-07-24 18:12 @800
Ubicación: Valladolid, España

Re: Problema usando servicios web

Notapor Alfumao » 2011-11-29 09:53 @453

¿Crees entonces que sería recomendable ponerse en contacto con los desarrolladores de la página para indicarles lo que sucede, y que ellos mismos arreglen el script y lo actualicen?

Les envié un mail con el error para intentar que lo solucionasen y me han remitido a la opción de bajarme un archivo WSDL para usar con SoapUI...

He visto en un post de este foro http://perlenespanol.com/foro/soap-lite-https-t6325.htmlque hay un módulo llamado SOAP::Lite que permitiría usar el archivo wsdl desde Perl. El post no me deja muy claro como debería mandar los archivos a analizar al servidor y como recogerlos. ¿Podríais arrojar algo de luz sobre el asunto?

Muchas gracias por la explicación anterior, explorer.
Alfumao
Perlero nuevo
Perlero nuevo
 
Mensajes: 178
Registrado: 2009-12-10 11:20 @514


Volver a Web

¿Quién está conectado?

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

cron