Skip to content

Apache CXF Hello World

Published:

工作需要,做个简单的记录

引用相关jar包

前往官网下载

或者使用gradle

// https://mvnrepository.com/artifact/org.apache.cxf/cxf
implementation("org.apache.cxf:cxf:4.0.4")

hello world示例

//创建接口类
@WebService
interface MyService {
    fun Hello(): String
}
//实现
class Main : MyService{
    override fun Hello(): String {
        return "Hello, World!"
    }
}
//创建服务
fun main(args: Array<String>) {
    Endpoint.publish("http://127.0.0.1:7001/service", Main())
}

之后浏览器访问http://127.0.0.1:7001/service?wsdl可查看wsdl


Previous Post
Apache CXF使用soap1.2协议