Je joue avec le SOAP::Lite module sur tous les deux côtés de serveur et client. Voilà le server.pl:
Le client suivant marche sans probleme:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 use SOAP::Transport::HTTP; my $daemon = SOAP::Transport::HTTP::Daemon->new(LocalAddr => localhost, LocalPort => 8000, Reuse => 1) ->dispatch_with({"urn:/HelloWorld" => "Hello"})->objects_by_reference("Hello"); $daemon->handle; package Hello; use SOAP::Lite; sub sayHello { my $self = shift; my $s = shift; return "let's say hello..."; }
Mais, si on essaie avec un client qui utilise WSDL:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9 use SOAP::Lite; use SOAP::Transport::HTTP; my $server = "http://localhost:8000"; my $urn = 'urn:/HelloWorld'; my $client = SOAP::Lite->uri($urn)->proxy($server); my $response = $client->sayHello("Hello, World!"); print $response->result . "\n";
et le proba.wsdl est défini avec:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5 my $soap = SOAP::Lite->service("file:proba.wsdl"); my $response = $soap->sayHello("Hello, World!"); print $response->result . "\n";
alors, une erreur est produit:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49 <?xml version="1.0" encoding="UTF-8"?> <definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="urn:/HelloWorld" tns="urn:/HelloWorld"> <!--<types> <s:schema targetNamespace="urn:HelloWorld"></s:schema> </types>--> <message name="sayHello"> <part name="name" type="xsd:string" /> <!--<part name="givenName" type="xsd:string" />--> </message> <message name="sayHelloResponse"> <part name="sayHelloResult" type="xsd:string" /> </message> <portType name="Service1Soap"> <operation name="sayHello"> <input message="tns:sayHello" /> <output message="tns:sayHelloResponse" /> </operation> </portType> <binding name="Service1Soap" type="tns:Service1Soap"> <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc" /> <operation name="sayHello"> <soap:operation soapAction="urn:/HelloWorld#sayHello"/> <input> <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> </input> <output> <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> </output> </operation> </binding> <service name="HelloWorld"> <port name="HelloWorldSoap" binding="tns:Service1Soap"> <soap:address location="http://localhost:8000" /> </port> </service> </definitions>
Can't locate object method "result" via package "let's say hello..." (perhaps you forgot to load "let's say hello..."?)
De quoi il s'agit ici?
La réponse est:
et je ne vois pas ici aucune problème.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9 <?xml version="1.0" encoding="UTF-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <soap:Body> <sayHelloResponse xmlns="urn:/HelloWorld"> <s-gensym9 xsi:type="xsd:string">let's say hello...</s-gensym9> </sayHelloResponse> </soap:Body> </soap:Envelope>
Quelque idée pourquoi la réponse n'est pas décomposé si le client est initialisé par le fichier de WSDL?
Merci en avance
Partager