How to register handlers with axis1.4 client program

5 pts.
Tags:
Tomcat
Web services
I have SimpleCalculator service up and running in Tomcat. Using its wsdl, I have created WSDL2java artifacts and written below standalone client program. It is working but when I added SimpleHandler to it, handlers are not working.
My client program as follows:
package wsclient.calc;
 
import java.net.URL;
 
import javax.xml.namespace.QName;
import javax.xml.rpc.Service;
import javax.xml.rpc.ServiceException;
import javax.xml.rpc.ServiceFactory;
import javax.xml.rpc.handler.*;
 
import ws.calc.generated.Calculator;
import ws.calc.generated.CalculatorService;
import ws.calc.generated.CalculatorServiceLocator;
import ws.calc.generated.CalculatorSoapBindingStub;
 
import java.rmi.RemoteException;
import java.util.*;
 
 
 
public class ClientWithHandlers {
 
  public static void main(String[] args) throws Exception 
 
  {
 HandlerInfo hi = new HandlerInfo();
      hi.setHandlerClass(SimpleHandler.class);
 
      QName  portName = new QName("urn:ws.calc", "Calculator");
         
      CalculatorServiceLocator locator = new CalculatorServiceLocator();  
 
      HandlerRegistry handlerRegistry = locator.getHandlerRegistry();
      List chain = handlerRegistry.getHandlerChain(portName);
      chain.add(hi);
      handlerRegistry.setHandlerChain(portName, chain);
     
      Calculator calc = locator.getcalculator();
      int ret = calc.add(1, 2);  
      System.out.println(ret);   
  }
}
Can someone suggest what is missing/wrong? Thanks in advance.

Software/Hardware used:
using java7 tomcat7 and axis1.4

Answer Wiki

Thanks. We'll let you know when a new response is added.

To register handlers with the Axis 1.4 client program, start by extending the BasicHandler provided by Axis. You must register it using client-config.wsdd. Then you will add the client-config.wsdd to the classpath of your server. The transport parameter is “http” and the pivot is Java.

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: