学习Axis2开发WebService

wcl_friend 2011-09-07 03:41:05
想用Axis2开发WebService接口,有没有帮助文档或者开发说明,各位大侠,能提供点帮助吗?

听说WebService的wsdl文件可以手写,然后通过命令打包成aar文件?

有这种实现方式吗?

怎么打包的?

命令怎么写?

...全文
86 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
淫生杯具 2011-09-08
  • 打赏
  • 举报
回复
附代码
service:

public class PolicyWS {
public AccidentPolicyResultsDTO getAccPolicyInfo(String name,String password,AccidentPolicyDTO[] accidentPolicyDTOs){
System.out.println(name+":"+password);
System.out.println("------");
if(accidentPolicyDTOs!=null&&accidentPolicyDTOs.length>0){
for (AccidentPolicyDTO dto : accidentPolicyDTOs) {
System.out.println(dto.getPolicyNo());
}
}
System.out.println("------");
AccidentPolicyResultsDTO dto=new AccidentPolicyResultsDTO();
dto.setErrorMessage("error");
dto.setResponseCode("1001");
dto.setTaskNo("1123");
AccidentPolicyResultDTO[] policyResultDTOs=new AccidentPolicyResultDTO[2];
AccidentPolicyResultDTO d1=new AccidentPolicyResultDTO();
d1.setErrorReason("for nothing");
d1.setPolicyNo("124123");
d1.setPolicySequenceNo("3123123");
d1.setSingleResponseCode("990");
AccidentPolicyResultDTO d2=new AccidentPolicyResultDTO();
d2.setErrorReason("for nothing");
d2.setPolicyNo("124125");
d2.setPolicySequenceNo("4123123");
d2.setSingleResponseCode("490");
policyResultDTOs[0]=d1;
policyResultDTOs[1]=d2;
dto.setPolicyResultDTOs(policyResultDTOs);
return dto;
}
}


client:

public class PolicyClient {

/**
* @param args
* @throws AxisFault
*/
public static void main(String[] args) throws AxisFault {
// TODO Auto-generated method stub
RPCServiceClient rpc=new RPCServiceClient();
Options options=rpc.getOptions();
EndpointReference endPoint=new EndpointReference("http://localhost:8088/axis2/services/PolicyWS");
options.setTo(endPoint);
Object[] params=new Object[]{"kyo","kyo",createThirdParam()};
Class[] returnClass=new Class[]{AccidentPolicyResultsDTO.class};
QName oper=new QName("http://ws.apache.org/axis2","getAccPolicyInfo");
Object[] result=rpc.invokeBlocking(oper, params, returnClass);
for (int i = 0; i < result.length; i++) {
AccidentPolicyResultsDTO dto=(AccidentPolicyResultsDTO)result[i];
System.out.println(dto.getErrorMessage()+";"+dto.getResponseCode()+":"+dto.getTaskNo());
for (AccidentPolicyResultDTO apr : dto.getPolicyResultDTOs()) {
System.out.println(apr.getErrorReason()+";"+apr.getPolicyNo()+";"+apr.getPolicySequenceNo()+";"+apr.getSingleResponseCode());
}
}
}

public static AccidentPolicyDTO[] createThirdParam(){
淫生杯具 2011-09-08
  • 打赏
  • 举报
回复
用tomcat运行axis2
下载axis2.war放到tomcat的webapps下
重启tomcat。会自动生成axis2文件夹
在axis2下的WEB-INF里,如果没有pojo文件夹则新建一个。
写一个service类,类名例如PolicyWS,写一个方法,return 一个String。
把service class拷到pojo下,service class相关联的类拷到pojo相并列的classes下。
启动tomcat,http://localhost:8088/axis2/services/listServices可以访问所有的webservice服务列表,用http://localhost:8088/axis2/services/PolicyWS?wsdl访问自动生成的wsdl。
飓风zj 2011-09-08
  • 打赏
  • 举报
回复
xfire
比较好 大众化
dragonsky_w 2011-09-08
  • 打赏
  • 举报
回复
我也在学习中,帮顶啊……
softroad 2011-09-08
  • 打赏
  • 举报
回复
http://axis.apache.org/axis2/java/core/下载文件里有例子的。
softroad 2011-09-08
  • 打赏
  • 举报
回复
随风醉舞 2011-09-08
  • 打赏
  • 举报
回复
没用过,lZ好运!
jiangdaxian2003 2011-09-07
  • 打赏
  • 举报
回复
[Quote=引用楼主 wcl_friend 的回复:]
想用Axis2开发WebService接口,有没有帮助文档或者开发说明,各位大侠,能提供点帮助吗?

听说WebService的wsdl文件可以手写,然后通过命令打包成aar文件?

有这种实现方式吗?

怎么打包的?

命令怎么写?
[/Quote]


axis2的wsdl不用写,是自动生成的,当打包成aar文件部署的时候,在浏览器输入endpoint url ?wsdl就可以看到.例如:http://1.2.3.4:8080/endpoint?wsdl就看到,至于怎么学习,网上找找,很多的
源点 2011-09-07
  • 打赏
  • 举报
回复
http://blog.csdn.net/wokao_wg/article/details/6615007

自己看吧。
oO临时工Oo 2011-09-07
  • 打赏
  • 举报
回复
http://blog.csdn.net/trocp/article/details/6757063

刚刚写的。LZ去看。不懂再联系。
cheng87716 2011-09-07
  • 打赏
  • 举报
回复
顶贴 接分
oO临时工Oo 2011-09-07
  • 打赏
  • 举报
回复
帮助文档可以到apache官网上去下

如果你要手动写wsdl就不需要axis了,这些在发布后都由axis自动生成的。

用上了axis你将不再需要命令,好比你用习惯了IDE你可能将不再希望用.txt

安心逍遥 2011-09-07
  • 打赏
  • 举报
回复
呃,axis2没用过,都是用xfire

帮顶了

祝楼主好运

81,091

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧