Salut tout le monde ,
alors voilà, je viens à vous car j'ai un soucis avec l'exemple venant avec le module sandesha d'axis 2.0 (protocole WS-ReliableMessaging).

En gros j'ai déployé le webservice d'exemple mais je n'arrive pas à faire tourner le client correctement. Quand j'exécute deux fois de suite le client les messages de réponse sont concatennés ! De plus si j'exécute l'exemple d'une autre machine elle reçoit comme réponse toute les réponses précédentes avec la sienne en plus. Donc si je tourne l'exemple une fois je vais recevoir comme réponse "echo1echo2echo3" et si je le relance, même d'une autre machine, je recevrai "echo1echo2echo3echo1echo2echo3". Quelqu'un à une idée ?

Voici le code (tout est dans une page JSP car ce n'est qu'un test technique):

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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<TITLE>index.jsp</TITLE>
</HEAD>
<BODY>
<h1> Test Technique Web Services</h1>
<h2> AXIS 2.0 Web Service Reliable Messaging Client</h2>
<P>Placez le contenu ici.</P>

<%!
private final static String applicationNamespaceName = "http://tempuri.org/"; 
private final static String echoString = "echoString";
private final static String Text = "Text";
private final static String Sequence = "Sequence";
private final static String echoStringResponse = "echoStringResponse";
private final static String EchoStringReturn = "EchoStringReturn";
private static String toEPR = "http://127.0.0.1:9080/axis2/services/RMSampleService";
private static String CLIENT_REPO_PATH = "c:\\Winprog\\WorkspacesRSA\\WSRMClient";
%>
<%!
private static OMElement getEchoOMBlock(String text, String sequenceKey) {
OMFactory fac = OMAbstractFactory.getOMFactory();
OMNamespace applicationNamespace = fac.createOMNamespace(applicationNamespaceName,"ns1");
OMElement echoStringElement = fac.createOMElement(echoString, applicationNamespace);
OMElement textElem = fac.createOMElement(Text,applicationNamespace);
OMElement sequenceElem = fac.createOMElement(Sequence,applicationNamespace);
textElem.setText(text);
sequenceElem.setText(sequenceKey);
echoStringElement.addChild(textElem);
echoStringElement.addChild(sequenceElem);
return echoStringElement;
}
static class TestCallback extends Callback {
String name = null;
public TestCallback (String name) {
this.name = name;
}
public void onComplete(AsyncResult result) {
SOAPBody body = result.getResponseEnvelope().getBody();
OMElement echoStringResponseElem = body.getFirstChildWithName(new QName (applicationNamespaceName,echoStringResponse));
OMElement echoStringReturnElem = echoStringResponseElem.getFirstChildWithName(new QName (applicationNamespaceName,EchoStringReturn));
String resultStr = echoStringReturnElem.getText();
System.out.println("Callback '" + name + "' got result:" + resultStr);
}
public void onError (Exception e) {
System.out.println("Error reported for test call back");
e.printStackTrace();
}
}
%>
<%

String axis2_xml = CLIENT_REPO_PATH + File.separator +"client_axis2.xml";
 
try{
System.out.println("-- Creation of context"); 
ConfigurationContext configContext = org.apache.axis2.context.ConfigurationContextFactory.createConfigurationContextFromFileSystem(CLIENT_REPO_PATH,axis2_xml);
 
System.out.println("-- Service client"); 
ServiceClient serviceClient = new ServiceClient (configContext,null);
System.out.println("Options");
Options clientOptions = new Options ();
System.out.println("-- YOP 5");
clientOptions.setTo(new EndpointReference(toEPR));
clientOptions.setTransportInProtocol(Constants.TRANSPORT_HTTP);
clientOptions.setUseSeparateListener(true);
serviceClient.setOptions(clientOptions);

System.out.println("-- Set Callback");
Callback callback1 = new TestCallback ("Callback 1");
serviceClient.sendReceiveNonBlocking (getEchoOMBlock("echo1","sequence1"),callback1);
Callback callback2 = new TestCallback ("Callback 2");
serviceClient.sendReceiveNonBlocking(getEchoOMBlock("echo2","sequence1"),callback2);

Callback callback3 = new TestCallback ("Callback 3");
serviceClient.sendReceiveNonBlocking(getEchoOMBlock("echo3","sequence1"),callback3);
 
clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true");
Callback callback4 = new TestCallback ("Callback 4");
serviceClient.sendReceiveNonBlocking(getEchoOMBlock("echo4","sequence2"),callback4);
System.out.println("-- before last while");
while (!callback3.isComplete()) {
Thread.sleep(1000);
}
System.out.println("-- before sleep");
 
Thread.sleep(4000); 
System.out.println("-- after sleep");
 
serviceClient.finalizeInvoke();
 
 
}catch (Exception e){
System.out.println("ERROR !!!!");
e.printStackTrace();
}
%>
</BODY>
</HTML>