码迷,mamicode.com
首页 > Web开发 > 详细

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

时间:2014-06-25 18:29:46      阅读:223      评论:0      收藏:0      [点我收藏+]

标签:style   class   blog   code   java   http   

 

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,布布扣,bubuko.com

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

标签:style   class   blog   code   java   http   

原文地址:http://www.cnblogs.com/friends-wf/p/3806052.html

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