码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2015-06-10 20:41:08      阅读:288      评论:0      收藏:0      [点我收藏+]

标签:

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目录下

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

标签:

原文地址:http://www.cnblogs.com/tongxinyuan/p/4567039.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!