Library

How do I avoid exposing all public methods as operations when deploying plain java class in Axis2?

  • By Deepal Jayasingha
  • 4 Aug, 2006
package org;

public class MyService {
public int add(int a , int b){
return a + b;
}
public int deduct(int a , int b){
return a - b;
}
public String echo(String str){
return str;
}
}

A: By default, all the above three public methods will be exposed as operations. So if you only want to expose two methods and exclude the third, you can just add a excludeOperations xml element in services.xml. For example, if you do not want to expose 'deduct' method then add following to your services.xml

<service name="MyService">
.........................................
<parameter name="ServiceClass">org.Myservice</parameter>
....................................
<excludeOperations>
<operation>deduct</operation>
</excludeOperations>
</service>

Applies To:

Apache Axis2/Java 1.0