Página 1 de 1

WWW::Mechanize peticiones GET

NotaPublicado: 2020-01-10 08:11 @382
por danimera
¿Cómo puedo hacer peticiones a un servicio web usando WWW::Mechanize GET pasándole parámetros?

La documentación dice esto:
Sintáxis: [ Descargar ] [ Ocultar ]
Using text Syntax Highlighting
get() is a well-behaved overloaded version of the method in LWP::UserAgent. This lets you do things like

$mech->get( $uri, ':content_file' => $tempfile );

and you can rest assured that the parms will get filtered down appropriately.
Coloreado en 0.000 segundos, usando GeSHi 1.0.8.4

También vi esto:
Sintáxis: [ Descargar ] [ Ocultar ]
Using text Syntax Highlighting
$ua->get( $url )
$ua->get( $url , $field_name => $value, ... )

This method will dispatch a GET request on the given $url. Further arguments can be given to initialize the headers of the request.
Coloreado en 0.000 segundos, usando GeSHi 1.0.8.4

Pero aun así no me funciona cuando reviso el Webservice; me dice parámetros NULL, pero cuando consumo un método que es con POST sí me funciona bien. Realmente he intentado usar hasta el URI.

Sintáxis: [ Descargar ] [ Ocultar ]
Using perl Syntax Highlighting
  1. my %parameters = (
  2.     key => 'value'
  3. );
  4. my $url = URI->new("http://example.com/i");
  5. $url->query_form(%parameters);
Coloreado en 0.002 segundos, usando GeSHi 1.0.8.4

También tengo este error:

<h1>Software error:</h1>
<pre>Error GETing http://localhost:8585/ws/XXXXX/XXX/vali ... nUsuario=1: Illegal character VCHAR='(' at C:/xampp/cgi-bin/wstest.cgi.pl line 205.
</pre>

Re: WWW::Mechanize peticiones GET

NotaPublicado: 2020-01-10 09:16 @428
por explorer
¿Has comprobado en los registros de actividad del servidor web (log) las peticiones GET que está recibiendo?

Es lo primero que haría, para ver si WWW::Mechanize está haciendo bien o mal la petición.

Re: WWW::Mechanize peticiones GET

NotaPublicado: 2020-01-10 09:20 @430
por danimera
Sí, claro que sí. Cuando uso un cliente postman o soapui mis parámetros son correctos y los recibe, los puedo imprimir en consola.

Pero con WMechanize Perl, no llega nunca nada, he revisado algunos parámetros en header tipo Transfer-Encoding = chunked en el postman y trato de aplicarlo pero ahora obtengo otros errores...

No he logrado poder hacer llegar los parámetros con Perl, pero sí con PostMan.

Re: WWW::Mechanize peticiones GET

NotaPublicado: 2020-01-11 10:14 @468
por danimera
Ya lo pude solucionar. Solo faltaba el json en el parámetro Content:

Sintáxis: [ Descargar ] [ Ocultar ]
Using perl Syntax Highlighting
  1. $mech->get($url, {}, Content => $jsonText);
Coloreado en 0.001 segundos, usando GeSHi 1.0.8.4