最近在做一个WinCE项目,数据交换全部使用的是WebService,使用C#也能很方便的测试(貌似C#的Web References比java的还好用,直接界面引入即可),但java测试还是很有必要的!
代码
import fnklAxiService.FnklAxiServiceServiceLocator;
import fnklAxiService.FnklAxiService_PortType;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.xml.rpc.ServiceException;
import java.rmi.RemoteException;
/**
* @author Jalena
* @version 1.0
*/
public class WebServiceTest {
private FnklAxiServiceServiceLocator locator;
private FnklAxiService_PortType service;
private final Logger logger = LoggerFactory.getLogger(getClass());
@Before
public void before(){
try {
logger.info("初始化!");
locator = new FnklAxiServiceServiceLocator();
service = locator.getfnklAxiService();
} catch (ServiceException e) {
logger.error("Service 异常",e);
}
}
@Test
public void fnTest(){
try {
String result = service.pdaDrupcrokQry("1054#001#2017-08-31#2017-08-31#HFHP201708310039");
logger.debug("\n" + result);
} catch (RemoteException e) {
logger.warn("服务连接错误!");
}
}
}
文章评论