5、编写业务代码。 双击com.add包下的文件AddSkeleton.java。 显示如下代码: package com.add; /** * AddSkeleton java skeleton for the axisService */ public class AddSkeleton{
/** * Auto generated method signature
* @param param0
*/ public com.add.xsd.AddResponse add ( com.add.xsd.Add param0 )
{ //Todo fill this with the necessary business logic throw new java.lang.UnsupportedOperationException("Please implement " + this.getClass().getName() + "#add"); }
}
修改后如下所示: package com.add; /** * AddSkeleton java skeleton for the axisService */ public class AddSkeleton{
/** * Auto generated method signature
* @param param0
*/ public com.add.xsd.AddResponse add ( com.add.xsd.Add request )
{ //Todo fill this with the necessary business logic
com.add.xsd.AddResponse response = new com.add.xsd.AddResponse(); int result = request.getInt1() + request.getInt2(); response.set_return(result); return response;
} }
保存。 然后编写测试代码: 双击test.com.add包下的AddTest.java文件 其中testadd()方法的代码显示如下: public void testadd() throws java.lang.Exception{
com.add.AddStub stub = new com.add.AddStub();//the default implementation should point to the right endpoint
com.add.AddStub.Add param4= (com.add.AddStub.Add)getTestObject(com.add.AddStub.Add.class); // todo Fill in the param4 here
assertNotNull(stub.add( param4));
} 修改为: public void testadd() throws java.lang.Exception{
java.lang.String url = "http://192.168.1.235:8080/axis2/services/Add"; com.add.AddStub stub = new com.add.AddStub(url);//the default implementation should point to the right endpoint com.add.AddStub.Add request= (com.add.AddStub.Add)getTestObject(com.add.AddStub.Add.class); // todo Fill in the param4 here