axis2 weibservice 入门
第一步:
下载axis2 bin war两个包
第二步:将war包解压
第三步:将解压出来的axis2 包放在tomcat app--发布目录下
第四步:在url中访问localhost:.........../axis2 出来成功页面 然后就可以看到产生了一个文件夹
第五:然后在该文件夹下web-inf新建pojo目录(只是默认可以再配置文件中修改)
然后编写一个pojo类 public class{ pubic String method(){}}
然后用javac将该文件编译生成.class文件 将字节码文件至于刚才新建的这个pojo目录下面。
第六:然后编写客户端程序
package mytest;
import javax.xml.namespace.QName;
import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.rpc.client.RPCServiceClient;
public class webServiceTest {
public static void main(String args[])throws Exception{
//rpc
RPCServiceClient client=new RPCServiceClient();
Options options=client.getOptions();
EndpointReference targetEPR=new EndpointReference("http://localhost:8090/axis2/services/SimpleService");
options.setTo(targetEPR);
Object[] opAddEntryArgs = new Object[] {"超人"};
//参数类型
Class[]classes = new Class[] {String.class};
// 指定要调用的getGreeting方法及WSDL文件的命名空间
QName opAddEntry = new QName("http://ws.apache.org/axis2","getGreeting");
// 调用getGreeting方法并输出该方法的返回值
System.out.println(":xxxxxxxxxxxxxxxxxx");
System.out.println(client.invokeBlocking(opAddEntry,opAddEntryArgs,classes)[0]);
}
}
这里注意要引入对应得一些个jar包 不然会报错。如果是涉及到mail的 那么引入mail.jar就ok.
大概情况就是这样。webservice还可以涉及到一些个短信平台的接入。。。。。