Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

239
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda