salut
j'ai créer un service web assez simple en utilisant eclipse+tomcat6+axis2
voila son code java
comme vous savez tous après création du service web un projet client sera créer automatiquement ayant transformé ma classe en une interface
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 public class pmp { public int k; public void setk(int h) { this.k=h; } public int getk() { return this.k; } }
voila le code
et d'autre classe vont aussi être créer automatiquement comme celle la
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 package DefaultNamespace; public interface Pmp extends java.rmi.Remote { public void setk(int h) throws java.rmi.RemoteException; public int getk() throws java.rmi.RemoteException; }
maintenant en créant mes propre page jsp qui utilise mon service web
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
50
51
52
53
54
55
56
57
58
59
60 package DefaultNamespace; public class PmpProxy implements DefaultNamespace.Pmp { private String _endpoint = null; private DefaultNamespace.Pmp pmp = null; public PmpProxy() { _initPmpProxy(); } public PmpProxy(String endpoint) { _endpoint = endpoint; _initPmpProxy(); } private void _initPmpProxy() { try { pmp = (new DefaultNamespace.PmpServiceLocator()).getpmp(); if (pmp != null) { if (_endpoint != null) ((javax.xml.rpc.Stub)pmp)._setProperty("javax.xml.rpc.service.endpoint.address", _endpoint); else _endpoint = (String)((javax.xml.rpc.Stub)pmp)._getProperty("javax.xml.rpc.service.endpoint.address"); } } catch (javax.xml.rpc.ServiceException serviceException) {} } public String getEndpoint() { return _endpoint; } public void setEndpoint(String endpoint) { _endpoint = endpoint; if (pmp != null) ((javax.xml.rpc.Stub)pmp)._setProperty("javax.xml.rpc.service.endpoint.address", _endpoint); } public DefaultNamespace.Pmp getPmp() { if (pmp == null) _initPmpProxy(); return pmp; } public void setk(int h) throws java.rmi.RemoteException{ if (pmp == null) _initPmpProxy(); pmp.setk(h); } public int getk() throws java.rmi.RemoteException{ if (pmp == null) _initPmpProxy(); return pmp.getk(); } }
j'ai fait ceci dans le jsp
et comme résultat j'aurai toujours 0 (valeur du constructeur par défaut)
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4 <%@ page import="DefaultNamespace.*" %> <%PmpProxy u=new PmpProxy(); u.setk(1); out.println(u.getk());%>
le problème que ça na pas été enregistré ?
Est ce qu'on peut déclarer des attribut dans un service web comme "k" pour moi?
Partager