Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

234
Views
How can I convert a method to asynchronous of my web service?

I currently have a web soap service method that works fine, but I would like to know how I can convert it to return a confirmation that the message has been received and that the client does not wait until I finish the process.

@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;
    ....................
  }

I would like to know how I can respond with an "OK" status and also the time.

    @WebService
    public abstract interface Students
    {

       @WebResult(name="response")
       @XmlElement(required=true, name="request")
       public abstract StudentResponse 
       getStudents(@WebParam(name="request") StudentRequest 
       request);

    }
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Hm interestingly enough this seems to the be inverse of the last question I answered, Howto Convert an async call to blocking.

So the steps are:

  • Execute the blocking call in a new thread.
  • Introduce a listener interface
  • Invoke the listener from the thread when the blocking call completed
  • Introduce a new async wrapper which can be invoked from the caller.

Assuming your blocking call is fooBlocking(), do:

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.");
        }
    }
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!