WebService之CXF注解之四(測试类)

Posted slgkaifa

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了WebService之CXF注解之四(測试类)相关的知识,希望对你有一定的参考价值。

TeacherTest.java:

/**
 * @Title:TeacherTest.java
 * @Package:com.test.service
 * @Description:
 * @author:Youhaidong(游海东)
 * @date:2014-5-5 下午11:14:09
 * @version V1.0
 */
package com.test.service;

import org.apache.cxf.interceptor.LoggingInInterceptor;
import org.apache.cxf.interceptor.LoggingOutInterceptor;
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;

import com.you.model.Teacher;
import com.you.service.ITeacherService;

/**
 * 类功能说明
 * 类改动者 改动日期
 * 改动说明
 * <p>Title:TeacherTest.java</p>
 * <p>Description:游海东个人开发</p>
 * <p>Copyright:Copyright(c)2013</p>
 * @author:游海东
 * @date:2014-5-5 下午11:14:09
 * @version V1.0
 */
public class TeacherTest 
{

	/**
	 * @Title:main
	 * @Description:
	 * @param:@param args
	 * @return: void
	 * @throws
	 */
	public static void main(String[] args) 
	{
		JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();    
        	factory.getInInterceptors().add(new LoggingInInterceptor());    
        	factory.getOutInterceptors().add(new LoggingOutInterceptor());    
        	factory.setServiceClass(ITeacherService.class);    
        	factory.setAddress("http://localhost:8686/Webservice/services/testTeacher");    
        	ITeacherService client = (ITeacherService) factory.create();  
        	Teacher teacher = new Teacher();  
        	teacher.setTeacherNum("2007101208");
        	teacher.setTeacherName("李思思");
        	teacher.setTeacherAge("38");
        	teacher.setTeacherSex("女");
        	teacher.setTeacherQQ("5623564545");
        	String info =  client.findTeacherInfo(teacher);  
        	System.out.println(info);  

	}

}




以上是关于WebService之CXF注解之四(測试类)的主要内容,如果未能解决你的问题,请参考以下文章

WebService之CXF注解之三(Service接口实现类)

cxf 调用webservice 时两句注解的意思

cxf调用c#的webservice

ios的单元測试OCUnit以及更新了之后的XCTestCase

学习webservice之cxf:使用webservice实现客户端

WebService系列二:使用JDK和CXF框架开发WebService