webservice 暴漏接口_WebService小白学习 之 使用CXF工具暴露接口 (2)

本文简要介绍了如何使用Apache CXF工具来快速暴露Webservice接口。通过在pom.xml中添加必要的CXF依赖,并修改Server.java代码,实现了接口的暴露。详细步骤包括设置暴露地址、接口类和服务实现类,最后成功启动Web Service。
摘要由CSDN通过智能技术生成

本篇介绍使用CXF工具暴露接口,不过多介绍,主要看代码。

实现过程:

1、在pom.xml添加CXF需要jar包:

org.apache.cxf

cxf-core

3.2.5

org.apache.cxf

cxf-rt-frontend-jaxws

3.2.5

org.apache.cxf

cxf-rt-transports-http-jetty

3.2.5

2、改动上篇的Server.java代码即可:

package com.gx.server;

import org.apache.cxf.jaxws.JaxWsServerFactoryBean;

import com.gx.webservice.IHelloWorld;

import com.gx.webservice.impl.HelloWorldImpl;

public class Server {

static String address = "http://127.0.0.1:34563/helloWorld";

public static void main(String[] args) {

System.out.println("web service start");

IHelloWorld implementor = new HelloWorldImpl();

JaxWsServerFactoryBean factoryBean = new JaxWsServerFactoryBean();

factoryBean.setAddress(address); //

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值