首页 > Web开发 > 详细

spingboot整合cxf生成webservice接口

时间:2020-05-15 22:51:23      阅读:89      评论:0      收藏:0      [点我收藏+]

一、pom文件设置

<dependency>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-spring-boot-starter-jaxws</artifactId>
    <version>3.3.6</version>
</dependency>
二、发布文件设置
@Configuration
public class WebServiceConfig {

    @Autowired
    private Bus bus;

    @Autowired
    private TestWebService testWebService;

    @Autowired
    private AuthHandler authHandler;

    @Bean
    public ServletRegistrationBean disServlet() {
        return new ServletRegistrationBean(new CXFServlet(), "/webservice/*");
    }

    @Bean
    public Endpoint endpoint() {
        EndpointImpl endpoint = new EndpointImpl(bus, testWebService);
        // 鉴权校验
        endpoint.getHandlers().add(authHandler);
        endpoint.publish("/test");
        return endpoint;
    }
}

三、service类

@WebService(targetNamespace = "http://service.springboot.dreamboat.com.cn")
public interface HelloWebService {

    @WebMethod
    @WSDLDocumentation( "测试webservice方法")
    RestResult<String> testWebServiceMethod(@WebParam(name = "methodParam") String methodParam);
}
@Slf4j
@WebService(serviceName = "TestWebService",
        targetNamespace = "http://service.springboot.dreamboat.com.cn",
        endpointInterface = "cn.com.dreamboat.springboot.service.HelloWebService"
)
@Component
public class HelloWebServiceImpl implements HelloWebService {

    @Override
    public RestResult<String> testWebServiceMethod(String methodParam) {
        // 业务...
        return RestResult.success(methodParam);
    }
}

四、打完收工~

 

spingboot整合cxf生成webservice接口

原文:https://www.cnblogs.com/timeflying/p/12897548.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!