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

webservice_cxf的配置

时间:2016-11-16 19:34:37      阅读:221      评论:0      收藏:0      [点我收藏+]

标签:local   started   div   str   ring   port   pre   int   ace   

先定义一个接口

import javax.jws.WebService;

@WebService
public interface HelloWorld {
    public void sayhi();
}

实现它

import javax.jws.WebService;

@WebService(endpointInterface="webservice_cxf.HelloWorld",serviceName="HelloWorld")  
public class HelloWorldImpl implements HelloWorld{

    public void sayhi() {
        System.out.println("hello world");
        
    }

}

发布它

import javax.xml.ws.Endpoint;

public class Public {
    public static void main(String[] args) {
        System.out.println("web service start");
        HelloWorld implementor = new HelloWorldImpl();
        String address = "http://localhost:8080/helloWorld";
        Endpoint.publish(address, implementor);
        System.out.println("+++web service started");
    }
}


测试它

public class Client {
    public static void main(String[] args) {
        JaxWsProxyFactoryBean jwpfb = new JaxWsProxyFactoryBean();
        jwpfb.setServiceClass(HelloWorld.class);
        jwpfb.setAddress("http://localhost:8080/helloWorld");
        HelloWorld hw = (HelloWorld) jwpfb.create();
        hw.sayhi();
    }
}

 

webservice_cxf的配置

标签:local   started   div   str   ring   port   pre   int   ace   

原文地址:http://www.cnblogs.com/flovatoblog/p/6071044.html

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