soap请求(axis2异步解析wsdl文件)

import java.text.SimpleDateFormat;
import java.util.Date;

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;

import util.ServiceAuthReq;
import util.ServiceAuthRsp;


public class Test {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		SimpleDateFormat sd = new SimpleDateFormat("yyyyMMddHHmmss");
		String s=sd.format(new Date());
		
		
		ServiceAuthReq a_req=new ServiceAuthReq();
		a_req.setUserID(s);
		
		try {
			RPCServiceClient client = new RPCServiceClient();
	        Options options = client.getOptions();   
	        //设置调用WebService的URL   
	        String address = "http://localhost:8080/testWebService/SPSysInterfacePort?wsdl";
	        EndpointReference epf = new EndpointReference(address);   
	        options.setTo(epf);  
	        
	        QName qname = new QName("http://ws.apache.org/axis2", "serviceAuth");  
	        Object[] result = client.invokeBlocking(qname, new Object[] { a_req }, new Class[] { ServiceAuthRsp.class }); 
	        ServiceAuthRsp ss=(ServiceAuthRsp) result[0];
	        System.out.println("result is " + ss.getResult());  
		} catch (AxisFault e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}  
	}

}

  这里要引入jar包-------------------------》网盘:axis2目录下

posted @ 2015-06-10 18:43  同心圆gt  阅读(1034)  评论(0编辑  收藏  举报