您的位置:首页 > 编程语言 > Java开发

学习webservice之cxf(1):使用cxf实现webservice(使用jdk1.8)

2020-05-25 07:51 711 查看

钉钉、微博极速扩容黑科技,点击观看阿里云弹性计算年度发布会!>>>

maven代码:

<dependencies>
<dependency>
<groupId>
1d36
;org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>3.2.5</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-core</artifactId>
<version>3.2.5</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
<version>3.2.5</version>
</dependency>
</dependencies>

 Server代码:

package com.rg2.webservice.impl;

import javax.xml.ws.Endpoint;

import org.apache.cxf.jaxws.JaxWsServerFactoryBean;

import com.rg2.webservice.HelloWorld;

public class Server {

public static void main(String[] args) {
System.out.println("web service start");
HelloWorld implementor = new HelloWorldImpl();
String address = "http://localhost/helloWorld";
//        Endpoint.publish(address, implementor);//jdk实现暴露webservice接口
JaxWsServerFactoryBean factoryBean = new JaxWsServerFactoryBean();
factoryBean.setAddress(address);//设置暴露地址
factoryBean.setServiceClass(HelloWorld.class);//接口类
factoryBean.setServiceBean(implementor);//设置实现类
factoryBean.create();//创建webservice接口
System.out.println("web service started");
}

}

 

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  apache apache cxf jdk jax-ws