我目前有一个运行良好的web soap服务方法,但我想知道如何将其转换为返回确认消息已收到,并且客户端不会等到我完成该过程。< / p>
@Service
@WebService(serviceName =
"getStudents",wsdlLocation="/wsdl/Students.wsdl")
public class StudentsImpl implements Students {
public StudentResponse getStudents(StudentRequest
request) {
**********************
}
}
public class StudentResponse
{
private String status;
private Date timeStamp;
....................
}
我想知道如何回应“OK”状态以及时间。
@WebService
public abstract interface Students
{
@WebResult(name="response")
@XmlElement(required=true, name="request")
public abstract StudentResponse
getStudents(@WebParam(name="request") StudentRequest
request);
}
答案 0 :(得分:0)
有趣的是,这似乎是我回答的最后一个问题的{em>逆,Howto Convert an async call to blocking。
所以步骤是:
假设您的阻止通话为fooBlocking()
,请执行:
public class MyKoolClass {
// .. kool functionalities here ...
public interface Listener {
void onTaskCompleted(String message);
}
public void fooAsyncWrapper() {
new FooTask(new Listener() {
@Override
public void onTaskCompleted(final String message) {
System.out.println("So complete, bruh" + message);
}
}).start();
}
public static class FooTask extends Thread {
Listener listener;
public FooTask(final Listener listener) {
this.listener = listener;
}
@Override
public void run() {
fooBlocking();
listener.onTaskCompleted("Sup baws.");
}
}