Bonjour,
J’espère poster dans la bonne section. Je m'initie aux "Web service" et j'essaie de mettre en place un simple programme réalisant une addition de deux nombres.
Pour ce faire, j'ai crée un WSDL (voir piece-jointe) puis à l'aide de WSDL2JAVA j'ai généré tous les fichiers Java.
Le service est déployé sur le serveur Tomcat puisque quand je tape : je peux lire :
me donne le fichier xml en pièce-jointe.PortAddition
Hi there, this is an AXIS service!
Perhaps there will be a form for invoking the service here...
Bon par contre quand je teste le service depuis mon navigateur
j'obtiens ceci :
Du coup j'essaye de créer un client sous eclipse.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 <soapenv:Envelope> <soapenv:Body> <soapenv:Fault> <faultcode>soapenv:Server.userException</faultcode> <faultstring> org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize. </faultstring> <detail> <ns1:hostname>Lucie-PC</ns1:hostname> </detail> </soapenv:Fault> </soapenv:Body> </soapenv:Envelope>
J'importe les fichiers générés, les fichiers bibliothèque.
notamment "B1Impl":
Puis je crée une classe test :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 /** * B1Impl.java * * This file was auto-generated from WSDL * by the Apache Axis 1.3 Oct 05, 2005 (05:23:37 EDT) WSDL2Java emitter. */ package Addition.Code; public class B1Impl implements Addition.Code.Addition_PortType{ public int addition2Nombres(int nombre1, int nombre2) throws java.rmi.RemoteException { return (nombre1+nombre2); } }
Sauf que quand je lance j'ai l'erreur suivante :
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 import java.net.URL; import org.apache.axis.client.Service; import org.apache.axis.utils.Options; import Addition.Code.B1Stub public class Test { public void Test1(String[] args) throws Exception { // Invoquer le service Web de la SE adjacente Options opts = new Options(args); opts.setDefaultURL("http://localhost:8080/axis/services/PortAddition"); java.net.URL endpointURL = new URL(opts.getURL()); Service service = new Service(); B1Stub stub = new B1Stub(endpointURL, service); //B1Stub stub = new B1Stub(); int somme; somme = stub.addition2Nombres(1, 2); //System.out.println(Integer.toString(somme)); } /** * @param args */ public static void main(String[] args) throws Exception { // TODO Auto-generated method stub Test test = new Test(); test.Test1(args); } }
Voila donc j’espère trouver quelqu'un capable de m'aider pour résoudre ce problème.Exception in thread "main" AxisFault
faultCode: {http://xml.apache.org/axis/}Client
faultSubcode:
faultString: No such operation 'nombre1'
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}hostname:Lucie-PC
No such operation 'nombre1'
at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:222)
at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:129)
at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087)
...
Je rajoute aussi le dossier du projet eclipse (fichier .rar) en piece jointe.
Partager