Hi,
 
I'm trying to write web service using Axis2 in REST style.
I created the following service as specified in one of the articles on the net and deployed it to Axis2 and everything seems to work fine (code first approach).
--------------------------------------------------------------------------------
/**
 * The service implementation class
 */
 
import java.util.HashMap;
 
public class SimpleService {
 
 /**
  * The echo method which will be exposed as the
  * echo operation of the web service
  */
 public String echo() {
  System.out.println("Echo test");
  return "Echo Successful";
 }
 
 public String echoString(String value) {
  System.out.println("value=" + value);
  StringBuffer sb = new StringBuffer("");
  sb.append("<USER>" + "\n" + "</USER>");
  return sb.toString();
 }
}
 
--------------------------------------------------------------------------------
The service works fine when i hit the following urls:
http://localhost:8080/axis2/rest/SimpleService/echo
http://localhost:8080/axis2/rest/SimpleService/echoString?param0=test
 
Then I tried "Contract first approach" by taking the wsdl that was generated for the above code and ran WSDL2Java utility to generate the service. I modified the skeleton service generated as shown below:
--------------------------------------------------------------------------------
    /**
     * SimpleServiceSkeleton.java
     *
     * This file was auto-generated from WSDL
     * by the Apache Axis2 version: SNAPSHOT Aug 03, 2006 (07:21:24 GMT+00:00)
     */
    package com.epocrates.webService;
    /**
     *  SimpleServiceSkeleton java skeleton for the axisService
     */
    public class SimpleServiceSkeleton{
    
  
        /**
         * Auto generated method signature
        
         
         */
        public  org.apache.ws.axis2.xsd.EchoResponse echo
                  (
         
          )
        
           {
  org.apache.ws.axis2.xsd.EchoResponse responseSt = new org.apache.ws.axis2.xsd.EchoResponse();
                //Todo fill this with the necessary business logic
                //throw new  java.lang.UnsupportedOperationException();
  responseSt.set_return("echo test successfull");
  return responseSt;
 
        }
    
  
        /**
         * Auto generated method signature
        
          * @param param2
        
         */
        public  org.apache.ws.axis2.xsd.EchoStringResponse echoString
                  (
          org.apache.ws.axis2.xsd.EchoString param2
          )
        
           {
  org.apache.ws.axis2.xsd.EchoStringResponse re = new org.apache.ws.axis2.xsd.EchoStringResponse();
                //Todo fill this with the necessary business logic
                //throw new  java.lang.UnsupportedOperationException();
  re.set_return("param0" + param2);
  return re;
        }
    
    }
    --------------------------------------------------------------------------------
Now accessing the URL http://localhost:8080/axis2/rest/SimpleService/echo , throws the following exception:
java.lang.NoSuchMethodError: com.epocrates.webService.SimpleServiceSkeleton.echo()Lorg/apache/ws/axis2/xsd/EchoResponse;
com.epocrates.webService.SimpleServiceMessageReceiverInOut.invokeBusinessLogic(SimpleServiceMessageReceiverInOut.java:50)
org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver.receive(AbstractInOutSyncMessageReceiver.java:39)
org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:492)
org.apache.axis2.transport.http.util.RESTUtil.invokeAxisEngine(RESTUtil.java:149)
org.apache.axis2.transport.http.util.RESTUtil.processGetRequest(RESTUtil.java:139)
.................................
and accessing http://localhost:8080/axis2/rest/SimpleService/echoString?param0=test, throws the following exception:
org.apache.axis2.AxisFault: java.lang.UnsupportedOperationException: This element was not created in a manner to be switched; nested exception is:
java.lang.RuntimeException: java.lang.UnsupportedOperationException: This element was not created in a manner to be switched; nested exception is:
org.apache.axis2.AxisFault: java.lang.UnsupportedOperationException: This element was not created in a manner to be switched; nested exception is:
java.lang.RuntimeException: java.lang.UnsupportedOperationException: This element was not created in a manner to be switched
org.apache.axis2.transport.http.util.RESTUtil.processGetRequest(RESTUtil.java:142)
org.apache.axis2.transport.http.AxisRESTServlet.doGet(AxisRESTServlet.java:36)
........................
Am I missing anything? Please help!!
 
Thanks,
Punya
 

Reply via email to