He intentado durante dos semanas crear un servicio web en Perl (con WSDL::Generator
) y llamarlo con un cliente escrito en Perl.No se puede ejecutar el servicio web Perl usando WSDL :: Generator
Ahora trato de los ejemplos proporcionados con la biblioteca está especializado en el WSDL: Soap::Lite
pero me da un error que sigue apareciendo
404 file not found at c.PL at line 7.
¿Puede ayudarme a resolverlo?
Aquí está mi código:
WorldFunctions.pm
(C: \ Perl \ de SOAP-Lite \ WorldFunctions.pm): la clase
package WorldFunctions;
sub new { bless {}, shift; }
sub Hello { my ($s, $name) = @_;
return 'Hello, ' . $name . "\n";
}
sub GoodBye { my ($s, $name) = @_;
return 'Goodbye, ' . $name . "\n";
}
a.pl
(C: \ Perl \ de SOAP-Lite \ a .pl): para crear el archivo WSDL del WorldFunctions.pm clase
#!/usr/bin/perl
use WSDL::Generator;
my $init = {
'schema_namesp' => 'http://localhost/world/WorldFunctions.xsd',
'services' => 'WorldFunctions',
'service_name' => 'WorldFunctions',
'target_namesp' => 'http://localhost/world',
'documentation' => 'Simple Hello World SOAP Service.',
'location' => 'http://localhost/world'
};
my $w = WSDL::Generator->new($init);
WorldFunctions->Hello('Joe');
WorldFunctions->GoodBye('Joe');
print $w->get(WorldFunctions); # Returns the WSDL code for a specific class
open(TOTO,"<a.wsdl");
close(TOTO);
open(TOTO,">a.wsdl");
print TOTO $w->get(WorldFunctions);
close(TOTO);
c.pl
(C: \ Perl \ de SOAP-Lite \ c.pl): archivo WSDL cliente Perl
#!/usr/bin/perl
use DBI();
use CGI;
use SOAP::Lite;
my $service = SOAP::Lite-> service('file:a.wsdl');
print "test retour : |".$service-> Hello('Joe')."|";
Sabiendo que utilizo un servidor local (con el servidor WAMP) y he copiado en mi directorio WorldFunctions.pm localhost/world.
Aquí está el archivo WSDL:
<?xml version="1.0"?>
<definitions name="WorldFunctions" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" targetNamespace="http://localhost/world" xmlns:tns="http://localhost/world" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:xsdl="http://localhost/world/WorldFunctions.xsd">
<types>
<xsd:schema targetNamespace="http://localhost/world/WorldFunctions.xsd">
<xsd:element name="GoodByeRequest" type="xsd:string" />
<xsd:element name="GoodByeResponse" type="xsd:string" />
<xsd:element name="HelloRequest" type="xsd:string" />
<xsd:element name="HelloResponse" type="xsd:string" />
</xsd:schema>
</types>
<message name="GoodByeRequest">
<part name="GoodByeRequestSoapMsg" element="xsdl:GoodByeRequest"/>
</message>
<message name="GoodByeResponse">
<part name="GoodByeResponseSoapMsg" element="xsdl:GoodByeResponse"/>
</message>
<message name="HelloRequest">
<part name="HelloRequestSoapMsg" element="xsdl:HelloRequest"/>
</message>
<message name="HelloResponse">
<part name="HelloResponseSoapMsg" element="xsdl:HelloResponse"/>
</message>
<portType name="WorldFunctionsWorldFunctionsPortType">
<operation name="GoodBye">
<input message="tns:GoodByeRequest" />
<output message="tns:GoodByeResponse" />
</operation>
<operation name="Hello">
<input message="tns:HelloRequest" />
<output message="tns:HelloResponse" />
</operation>
</portType>
<binding name="WorldFunctionsWorldFunctionsBinding" type="tns:WorldFunctionsWorldFunctionsPortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="GoodBye">
<soap:operation style="document" soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
<operation name="Hello">
<soap:operation style="document" soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="WorldFunctions">
<documentation>
Simple Hello World SOAP Service.
</documentation>
<port name="WorldFunctionsWorldFunctionsPort" binding="tns:WorldFunctionsWorldFunctionsBinding">
<soap:address location="http://localhost/world"/>
</port>
</service>
</definitions>
¿Seguro de los archivos que está intentando tener acceso son realmente allí? ¿Puedes cargarlos en un navegador GUI? –
lo siento Brian, llego tarde para responderte! pero los archivos se colocan en el lugar correcto y son accesibles – Wael
Estoy atascado en otro problema: cuando ejecuto el código que sigue, se mostrará el error "No se pudo encontrar o cargar mod_perl en C:/Perl/sitio/lib/SOAP/Transporte/HTTP.pm línea 741 " pero he instalado el módulo de éxito mod_apache2 Aquí está el código: ' code' #/usr/bin/perl uso de SOAP :: Transporte :: HTTP; SOAP :: Transporte :: HTTP :: Apache -> dispatch_to ('WorldFunctions') -> handle; paquete WorldFunctions; sub nuevo {bless {}, shift; } 'code' – Wael