我为部署在 WSO2ESB 上的 WebService 生成了一个 Java 客户端,通过这个客户端,我尝试使用循环和睡眠发送定期请求,但我收到了相同的响应(值,WS 接收请求的时间,发送时间响应) !!
我有存根类,我在主类中调用的 Java 客户端是:
package org.wso2.cs.helloservices;
import java.rmi.RemoteException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import org.wso2.cs.helloservices.HelloProviderStub.SayHello;
import org.wso2.cs.helloservices.HelloProviderStub.SayHelloResponse;
public class Consumer {
public ArrayList <SayHelloResponse> consumer(int requestsNumber, int sleep, int reliability) throws
RemoteException, InterruptedException{
ArrayList <SayHelloResponse> listResp = new ArrayList<SayHelloResponse>();
HelloProviderStub Stub= new HelloProviderStub();
for (int i=0; i<requestsNumber; i++){
Thread.sleep(3000);
SayHello request=new SayHello();
SimpleDateFormat dateFormat = new SimpleDateFormat("mm:ss");
request.setSleep(sleep);
request.setReliability(reliability);
SayHelloResponse resp=Stub.sayHello(request);
listResp.add(resp);
}
return listResp;
}
}
例如,响应是:
Result of Request: 1
---------------------
Receiving Request : 2013:01:24:21:22:30:00935
Sending Response : 2013:01:24:21:22:31:00935
Response : Test
Result of Request: 2
---------------------
Receiving Request : 2013:01:24:21:22:30:00935
Sending Response : 2013:01:24:21:22:31:00935
Response : Test
请有任何建议。