Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

233
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda