You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-user@xml.apache.org by Tim De Vos <ti...@evision.be> on 2001/02/21 09:53:04 UTC

Multithreading in SOAP

Hello everyone!

I`m working with the Apache SOAP toolkit to interrogate an EJB server.
Everything works
fine as long as I sent a request and wait until the server answers. Now I
rewrote
my code so that SOAP calls are sended multithreaded and the answer is
recieved
multithreaded. Here is a code extract:

    SOAPMappingRegistry smr = new SOAPMappingRegistry();
    BeanSerializer beanSer = new BeanSerializer();

     // Construct a call
    Call call = new Call();

    Response resp;

    synchronized(call) {
      call.setSOAPMappingRegistry(smr);
      call.setTargetObjectURI(fTargetObjectURI);
      call.setMethodName(fMethodName);
      call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);

      if (fParamList != null && fParamList.size() > 0) {
       call.setParams(fParamList);
      }


      // Invoke the call.
      Response resp;

      try {
        System.err.print("Calling ...");
        resp = call.invoke(fURL, "");
        System.err.println("done");
       }
       catch (SOAPException e) {
            // ...
            return;
       }
  }

    new Thread(new ProcessResponse(resp)).start();

The response is handled in a seperate thread:

public void run() {
  // Check the response.
  if (!fResp.generatedFault()) {
   System.err.print("Checking the response ...");
   Parameter ret = fResp.getReturnValue();

   String returnValue = (String)ret.getValue();

   // initialise the parser
   try {
    ...
  }
  else {
   Fault fault = fResp.getFault();

   System.err.println("Generated fault: ");
   System.out.println ("  Fault Code   = " + fault.getFaultCode());
   System.out.println ("  Fault String = " + fault.getFaultString());
  }
 }

It doesn`t work. And maybe it`s obvious that you can`t make SOAP
multithreaded. Any idea whether it is
possible to make SOAP multithreaded?

Thanks in advance for replying

Tim De Vos