Bonjour à tous j'ai réussi à faire un web service en utilisant axis 1.4 mais impossible de porter mon code sous Axis2 et finalement je suis obligé d'utiliser Axis2.... comment faire ?
Merci d'avance :
Client :
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 import java.net.URL; import javax.xml.namespace.QName; import org.apache.axis.client.Call; import org.apache.axis.client.Service; public class EmployeClient { public static void main(String [] args) throws Exception { Service service = new Service(); Call call = (Call)service.createCall(); String endpoint = "http://localhost:8080/axis/services/EmployeService"; call.setTargetEndpointAddress(new URL(endpoint)); call.setOperationName(new QName("getCurrentID")); String dept = "marketing"; String name = "sacha"; String position = (String)call.invoke(new Object [] {new String(dept), new String(name)}); System.out.println("Résultat de la recherche : " + position ); } }
Serveur :
je vous remercie d'avance pour votre aide !
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 import java.util.*; public class EmployeService { HashMap tab = new HashMap(); public EmployeService() { tab.put("marketing/elena", "40"); tab.put("marketing/sacha", "35"); tab.put("comptabilite/frank", "23"); tab.put("comptabilité/toto", "29"); } public String getCurrentID(String dept, String name) { String p = (String)tab.get(dept + '/' + name ); if (p==null) return "L'employé n'a pas été trouvé"; else return p; } }
Partager