ws javaee实现方式以及TgsWebservice中 MQ发送延迟问题(柬埔寨项目)

package client;

import java.util.ArrayList;
import java.util.List;

import org.apache.cxf.endpoint.Client;
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import t.ITest222;
import t.ITests;
import t.TestPojo;

public class Test {
	ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
	//不行
	public static void test(){
//		JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
//		factory.setServiceClass(ITest222.class);
//		factory.setAddress("http://192.168.1.26:9085/WS_AXIS_WSS/service/test222");
//		ITest222 service = (ITest222) factory.create();
//
//		service.insertFlowInfos();
		
		
//		t.start();
		int i = 0;
		while(i<300){
			//如果放在外面,都是相同的Thread对象,如果上一次的线程没运行结束,又要start一次,就会报错
			//mq关停的两种方式的区别,延迟问题已解决
			Thread t = new Thread(new Runnable(){
				public void run() {
					JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();  
//					String wsUrl = "http://192.168.1.26:8089/WS_CXF/CxfTest?wsdl"; 
//					String method = "test";  
					 String wsUrl = "http://127.0.0.1:8081/TgsWebService/TgsFuncitonPort?wsdl";   
					 String method = "insertPassedCar";  
					Client client = dcf.createClient(wsUrl); 
					Object[] res = null; 
						try {
							res = client.invoke(method, "01","鲁C12322","2015-1-1 1:1:1","321323000000000001","3","321323000000","3","3","3","3","3","http://192.168.1.26/ZTEDATAD/北京中路与相文路/卡口/由东向西/2015012914/北京中路与相文路$20150129143404$由东向西$苏NDM803.jpg","2","2","2");
						} catch (java.lang.Exception e) {
							e.printStackTrace();
						}
					System.out.println("res: "+res[0]);
				}
			});
			
			t.start();
			try {
				Thread.sleep(1000);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	}
	/**
	 * wsdl地址,接口和接口的路径
	 */
	public static void clientToXML(){
		JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
		factory.setServiceClass(ITests.class);
		factory.setAddress("http://192.168.1.26:8089/WS_CXF/CxfTest");
		ITests service = (ITests) factory.create();
		TestPojo tp = new TestPojo();
		tp.setAge("22岁");
		tp.setHigh("185米");
		tp.setName("lvxianchao");
		List<TestPojo> list = new ArrayList<TestPojo>();
		list.add(tp);
		list.add(tp);
		list.add(tp);
		String str = service.test2(list);
		System.out.println("str: "+str);
		
		String str2 = service.test("lvxianchao");
		System.out.println("str2: "+str2);

	}
	
	/**
	 * 只有wsdl地址的写法,还有方法名和参数
	 */
	public static void noImplClass(){
		JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();  
//		String wsUrl = "http://192.168.1.26:8089/WS_CXF/CxfTest?wsdl"; 
//		String method = "test";  
		 String wsUrl = "http://192.168.1.26:8088/TgsWebService/TgsFuncitonPort?wsdl";   
		 String method = "insertPassedCar";  
		Client client = dcf.createClient(wsUrl); 
		Object[] res = null; 
			try {
				res = client.invoke(method, "lvxianchao");
			} catch (java.lang.Exception e) {
				e.printStackTrace();
			}
		System.out.println("res: "+res.length+"\n"+res[0]);

	}
	
	public static void main(String[] args) {
//	    clientToXML();
//		noImplClass();
		test();
	}
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值