cxf利用接口规范写法发布webservice

 

1 package cn.itcast.cxf;
2 
3 import javax.jws.WebService;
4 
5 @WebService
6 public interface IHelloService {
7     public String sayHello(String name);
8 }

 

 1 package cn.itcast.cxf;
 2 
 3 import java.text.SimpleDateFormat;
 4 import java.util.Date;
 5 
 6 
 7 import org.apache.cxf.interceptor.LoggingInInterceptor;
 8 import org.apache.cxf.interceptor.LoggingOutInterceptor;
 9 import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
10 
11 
12 public class HelloServiceImpl implements IHelloService {
13 
14     @Override
15     public String sayHello(String name) {
16         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
17         return sdf.format(new Date())+ " ---hello " + name;
18     }
19     public static void main(String[] args) {
20         JaxWsServerFactoryBean bean = new JaxWsServerFactoryBean();
21         bean.setAddress("http://192.168.1.112:7788/hello");
22         bean.setServiceClass(IHelloService.class);//接口类型
23         bean.setServiceBean(new HelloServiceImpl());
24         //加入请求消息拦截器
25         bean.getInInterceptors().add(new LoggingInInterceptor());
26         //加入响应消息拦截器
27         bean.getOutInterceptors().add(new LoggingOutInterceptor());
28         bean.create();
29         System.out.println("server ready...");
30     }
31 
32 }

 

cxf利用接口规范写法发布webservice,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。