我为部署在WSO2ESB上的WebService生成了一个Java客户端,通过此客户端,我尝试使用循环和Sleep发送周期性请求,但我收到了相同的响应(值,WS接收请求的时间,发送回复的时间)!!
我有Stub类,我在Main Class中调用的My Java Client是:
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
请提出任何建议。
答案 0 :(得分:0)
可能是缓存生成的响应看起来相同。如果允许此功能正常运行,则服务将打开以进行DoS(拒绝服务)攻击。