1、注释生成
在axis2+Spring结合发布的场合,客服端调用时,接口函数参数的默认名称为axis2的默认设置(如arg0),而调用方更想看到的是具体参数的名称(如:testName)。
package wip;
import javax.jws.WebParam;
import javax.jws.WebResult;
public interface WebDao{
@WebResult(name = "getTest")
public String getTest(@WebParam(name = "testName")String testName);
}
2、解决 WebResult注释无效问题
无论WebResult如何设置,方法返回值变量名都是默认“return”,看了axis2的源码后, 最终将范围定为到:
axis2项目的axis2-kernel-1.6.2.jar中的
org.apache.axis2.description.java2wsdl.DefaultSchemaGenerator 类
org.apache.axis2.description.java2wsdl.DocLitBareSchemaGenerator 类
对于上面两个类需要做如下修改:
protected Method[] processMethods(Method[] declaredMethods) throws Exception {
...................
WebResultAnnotation returnAnnon = JSR181Helper.INSTANCE.getWebResultAnnotation(jMethod);
String returnName = "return";
if (returnAnnon != null) {
returnName = returnAnnon.getName();
//原来的代码 if (returnName != null && !"".equals(returnName)) {
if (returnName == null || "".equals(returnName)) {
returnName = "return";
}
}
...................
}