- 浏览: 2557345 次
- 性别:
- 来自: 成都
文章分类
最新评论
-
nation:
你好,在部署Mesos+Spark的运行环境时,出现一个现象, ...
Spark(4)Deal with Mesos -
sillycat:
AMAZON Relatedhttps://www.godad ...
AMAZON API Gateway(2)Client Side SSL with NGINX -
sillycat:
sudo usermod -aG docker ec2-use ...
Docker and VirtualBox(1)Set up Shared Disk for Virtual Box -
sillycat:
Every Half an Hour30 * * * * /u ...
Build Home NAS(3)Data Redundancy -
sillycat:
3 List the Cron Job I Have>c ...
Build Home NAS(3)Data Redundancy
SpringBoot 2 and CXF Happy Hour
First of all, the based core configuration pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.sillycat.springbootcxf</groupId>
<artifactId>spring-boot2-cxf</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>spring-boot2-cxf</name>
<description>Demo project for using Spring Boot Starter CXF</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.2.RELEASE</version>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>cxf-spring-boot-starter</artifactId>
<version>2.1.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>de.codecentric</groupId>
<artifactId>cxf-spring-boot-starter-maven-plugin</artifactId>
<version>2.0.0.RELEASE</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Place the WSDL file in the class path like /src/main/resources/wsdl/
Generate Source Command
> mvn generate-sources
Health Page
http://localhost:50301/actuator/health
WSDL
http://localhost:50301/services/TroubleshootWebServiceFS?wsdl
Controller Sample
http://localhost:50301/api/hello/mini
Chrome Plugin
https://chrome.google.com/webstore/detail/wizdler/oebpmncolmhiapingjaagmapififiakb
The configuration application.yaml will be as follow:
soap:
service:
base:
url: /services
publishedEndpointUrl: http://localhost:50301/services/TroubleshootWebServiceFS
messages:
logging: true
extract: true
cxf:
servicelist:
title: Spring Boot2 CXF
info:
app:
name: Spring Boot 2 CXF
java:
version: 1.0.0
type: Microservice API
server:
address: 0.0.0.0
port: 50301
management:
endpoints:
web:
exposure:
include: health,info
The simple Main Java Class
package com.sillycat.springbootcxf;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
@SpringBootApplication
public class SpringBootCXFApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(SpringBootCXFApplication.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(SpringBootCXFApplication.class);
}
}
The Endpoint which provide the implementation of the service
package com.sillycat.springbootcxf.endpoint;
import java.util.UUID;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.intuit.developer.ArrayOfString;
import com.intuit.developer.TroubleshootWebServiceFSSoap;
import com.sillycat.springbootcxf.service.HelloService;
@Service
public class TroubleshootWebServiceFSSoapEndpoint implements TroubleshootWebServiceFSSoap {
protected final Logger LOGGER = LoggerFactory.getLogger(this.getClass());
@Autowired
HelloService helloService;
@Override
public String serverVersion() {
LOGGER.info("enter method server version");
return "1.0";
}
@Override
public String clientVersion(String strVersion) {
LOGGER.info("enter method client version");
return null;
}
@Override
public ArrayOfString authenticate(String strUserName, String strPassword) {
LOGGER.info("enter method authenticate, strUserName:" + strUserName + " strPassword:" + strPassword);
ArrayOfString arrayOfString = new ArrayOfString();
arrayOfString.getString().add(UUID.randomUUID().toString());
arrayOfString.getString().add("NONE");
helloService.sayHello("YiYi Kang");
return arrayOfString;
}
@Override
public String connectionError(String ticket, String hresult, String message) {
// TODO Auto-generated method stub
return null;
}
@Override
public String sendRequestXML(String ticket, String strHCPResponse, String strCompanyFileName, String qbXMLCountry,
int qbXMLMajorVers, int qbXMLMinorVers) {
// TODO Auto-generated method stub
return null;
}
@Override
public int receiveResponseXML(String ticket, String response, String hresult, String message) {
// TODO Auto-generated method stub
return 0;
}
@Override
public String getLastError(String ticket) {
// TODO Auto-generated method stub
return null;
}
@Override
public String closeConnection(String ticket) {
// TODO Auto-generated method stub
return null;
}
}
The sample project is here
https://github.com/yiyikang/spring-boot2-cxf
References:
https://github.com/codecentric/spring-samples/tree/master/cxf-boot-simple
https://github.com/codecentric/cxf-spring-boot-starter
https://blog.codecentric.de/en/2016/10/spring-boot-apache-cxf-spring-boot-starter/
https://github.com/codecentric/cxf-spring-boot-starter/blob/ff24b290ab88cfe2f6bfe52de9a247276bcd26fe/src/main/java/de/codecentric/cxf/configuration/CxfAutoConfiguration.java
First of all, the based core configuration pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.sillycat.springbootcxf</groupId>
<artifactId>spring-boot2-cxf</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>spring-boot2-cxf</name>
<description>Demo project for using Spring Boot Starter CXF</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.2.RELEASE</version>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>cxf-spring-boot-starter</artifactId>
<version>2.1.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>de.codecentric</groupId>
<artifactId>cxf-spring-boot-starter-maven-plugin</artifactId>
<version>2.0.0.RELEASE</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Place the WSDL file in the class path like /src/main/resources/wsdl/
Generate Source Command
> mvn generate-sources
Health Page
http://localhost:50301/actuator/health
WSDL
http://localhost:50301/services/TroubleshootWebServiceFS?wsdl
Controller Sample
http://localhost:50301/api/hello/mini
Chrome Plugin
https://chrome.google.com/webstore/detail/wizdler/oebpmncolmhiapingjaagmapififiakb
The configuration application.yaml will be as follow:
soap:
service:
base:
url: /services
publishedEndpointUrl: http://localhost:50301/services/TroubleshootWebServiceFS
messages:
logging: true
extract: true
cxf:
servicelist:
title: Spring Boot2 CXF
info:
app:
name: Spring Boot 2 CXF
java:
version: 1.0.0
type: Microservice API
server:
address: 0.0.0.0
port: 50301
management:
endpoints:
web:
exposure:
include: health,info
The simple Main Java Class
package com.sillycat.springbootcxf;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
@SpringBootApplication
public class SpringBootCXFApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(SpringBootCXFApplication.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(SpringBootCXFApplication.class);
}
}
The Endpoint which provide the implementation of the service
package com.sillycat.springbootcxf.endpoint;
import java.util.UUID;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.intuit.developer.ArrayOfString;
import com.intuit.developer.TroubleshootWebServiceFSSoap;
import com.sillycat.springbootcxf.service.HelloService;
@Service
public class TroubleshootWebServiceFSSoapEndpoint implements TroubleshootWebServiceFSSoap {
protected final Logger LOGGER = LoggerFactory.getLogger(this.getClass());
@Autowired
HelloService helloService;
@Override
public String serverVersion() {
LOGGER.info("enter method server version");
return "1.0";
}
@Override
public String clientVersion(String strVersion) {
LOGGER.info("enter method client version");
return null;
}
@Override
public ArrayOfString authenticate(String strUserName, String strPassword) {
LOGGER.info("enter method authenticate, strUserName:" + strUserName + " strPassword:" + strPassword);
ArrayOfString arrayOfString = new ArrayOfString();
arrayOfString.getString().add(UUID.randomUUID().toString());
arrayOfString.getString().add("NONE");
helloService.sayHello("YiYi Kang");
return arrayOfString;
}
@Override
public String connectionError(String ticket, String hresult, String message) {
// TODO Auto-generated method stub
return null;
}
@Override
public String sendRequestXML(String ticket, String strHCPResponse, String strCompanyFileName, String qbXMLCountry,
int qbXMLMajorVers, int qbXMLMinorVers) {
// TODO Auto-generated method stub
return null;
}
@Override
public int receiveResponseXML(String ticket, String response, String hresult, String message) {
// TODO Auto-generated method stub
return 0;
}
@Override
public String getLastError(String ticket) {
// TODO Auto-generated method stub
return null;
}
@Override
public String closeConnection(String ticket) {
// TODO Auto-generated method stub
return null;
}
}
The sample project is here
https://github.com/yiyikang/spring-boot2-cxf
References:
https://github.com/codecentric/spring-samples/tree/master/cxf-boot-simple
https://github.com/codecentric/cxf-spring-boot-starter
https://blog.codecentric.de/en/2016/10/spring-boot-apache-cxf-spring-boot-starter/
https://github.com/codecentric/cxf-spring-boot-starter/blob/ff24b290ab88cfe2f6bfe52de9a247276bcd26fe/src/main/java/de/codecentric/cxf/configuration/CxfAutoConfiguration.java
发表评论
-
Update Site will come soon
2021-06-02 04:10 1683I am still keep notes my tech n ... -
Stop Update Here
2020-04-28 09:00 320I will stop update here, and mo ... -
NodeJS12 and Zlib
2020-04-01 07:44 482NodeJS12 and Zlib It works as ... -
Docker Swarm 2020(2)Docker Swarm and Portainer
2020-03-31 23:18 373Docker Swarm 2020(2)Docker Swar ... -
Docker Swarm 2020(1)Simply Install and Use Swarm
2020-03-31 07:58 373Docker Swarm 2020(1)Simply Inst ... -
Traefik 2020(1)Introduction and Installation
2020-03-29 13:52 341Traefik 2020(1)Introduction and ... -
Portainer 2020(4)Deploy Nginx and Others
2020-03-20 12:06 433Portainer 2020(4)Deploy Nginx a ... -
Private Registry 2020(1)No auth in registry Nginx AUTH for UI
2020-03-18 00:56 441Private Registry 2020(1)No auth ... -
Docker Compose 2020(1)Installation and Basic
2020-03-15 08:10 379Docker Compose 2020(1)Installat ... -
VPN Server 2020(2)Docker on CentOS in Ubuntu
2020-03-02 08:04 461VPN Server 2020(2)Docker on Cen ... -
Buffer in NodeJS 12 and NodeJS 8
2020-02-25 06:43 391Buffer in NodeJS 12 and NodeJS ... -
NodeJS ENV Similar to JENV and PyENV
2020-02-25 05:14 482NodeJS ENV Similar to JENV and ... -
Prometheus HA 2020(3)AlertManager Cluster
2020-02-24 01:47 428Prometheus HA 2020(3)AlertManag ... -
Serverless with NodeJS and TencentCloud 2020(5)CRON and Settings
2020-02-24 01:46 340Serverless with NodeJS and Tenc ... -
GraphQL 2019(3)Connect to MySQL
2020-02-24 01:48 252GraphQL 2019(3)Connect to MySQL ... -
GraphQL 2019(2)GraphQL and Deploy to Tencent Cloud
2020-02-24 01:48 454GraphQL 2019(2)GraphQL and Depl ... -
GraphQL 2019(1)Apollo Basic
2020-02-19 01:36 330GraphQL 2019(1)Apollo Basic Cl ... -
Serverless with NodeJS and TencentCloud 2020(4)Multiple Handlers and Running wit
2020-02-19 01:19 316Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(3)Build Tree and Traverse Tree
2020-02-19 01:19 323Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(2)Trigger SCF in SCF
2020-02-19 01:18 298Serverless with NodeJS and Tenc ...
相关推荐
2. 配置SpringBoot的主类,启用CXF的自动配置。 3. 使用CXF的注解或Java配置定义Web服务接口和实现。 4. 创建并运行SpringBoot应用,CXF将会自动启动并暴露Web服务。 在给定的压缩包文件中,"WebService_Server...
在IT行业中,Spring Boot和Apache CXF是两个非常重要的组件,它们在开发高效、轻量级的Web服务中发挥着关键作用。本文将详细介绍如何在Spring Boot 2.1.5版本中集成CXF 3.2.5,以创建一个功能完备的Web Service...
SpringBoot整合CXF是将流行的Java Web服务框架CXF与SpringBoot轻量级框架结合,以便更方便地创建和消费Web服务。这个项目提供了一个很好的示例,通过详细注释帮助开发者理解如何在SpringBoot应用中发布和调用Web服务...
webserviceApache CXF java springboot利用Apache CXF创建webserice接口 Apache CXF 核心架构是以BUS为核心,整合其他组件。 * Bus是CXF的主干, 为共享资源提供一个可配置的场所,作用类似于Spring的...
【Springboot整合cxf测试项目】是一个实际应用了Spring Boot与Apache CXF框架集成的案例,主要用于构建Web服务。Spring Boot以其便捷的初始化配置和自动配置功能,简化了项目的搭建过程,而Apache CXF则是一个强大的...
2. **CXF集成**:SpringBoot可以通过`spring-boot-starter-cxf`依赖来引入CXF。在配置文件`application.properties`或`application.yml`中,我们可以设置CXF的端点地址和其他相关配置。 3. **服务发布**:在服务...
wsdl2java源码springboot-apachecxf-client 本项目演示了如何在Springboot中实现apachecxf客户端,以及如何为客户端调用生成wsdltojava。 Springboot-apachecxf-jaxws 示例 此应用程序展示了如何使用 apachecxf ...
SpringBoot+Mybatis+CXF框架,实现Restful api与 WebService api接口的大实验 本实验的主要目标是使用SpringBoot、Mybatis和CXF框架来实现Restful API和WebService API接口的大实验。下面是实验的详细介绍: 标题...
CXF提供了`wsdl2java`工具,可以基于Web服务的WSDL文件生成客户端代码。你可以使用Maven的CXF插件或者命令行工具来执行此操作。 生成客户端代码后,你可以在Spring Boot客户端应用中引入这些生成的类,并使用它们来...
springboot cxf下载上传springboot cxf下载上传springboot cxf下载上传springboot cxf下载上传springboot cxf下载上传springboot cxf下载上传springboot cxf下载上传springboot cxf下载上传springboot cxf下载上传...
在IT行业中,SpringBoot、WebService和cxf是三个非常重要的技术组件,它们分别代表了现代Java应用程序开发的基础、服务间通信的重要方式以及一种强大的服务框架。在这个主题中,我们将深入探讨如何在SpringBoot项目...
在本项目"springboot_cxf_security"中,我们主要探讨的是如何将Spring Boot、Apache CXF和Spring Security整合,以创建一个集成了Web服务(Webservice)和模型视图控制器(MVC)功能的应用程序。以下是对这些技术的...
cxf整合springboot项目开发文档实例cxf整合springboot项目开发文档实例cxf整合springboot项目开发文档实例
SpringBoot和CXF都提供了多种安全策略,如OAuth2、Basic认证、SSL/TLS等,可以根据项目需求进行配置。 通过以上步骤,我们可以利用SpringBoot和CXF的强大功能快速构建和部署Web服务。在`springboot_wscxf`这个项目...
这里`2.x.x.RELEASE`和`3.x.x.RELEASE`需要替换为实际的Spring Boot和CXF版本号。 接下来,我们需要创建一个CXF的Web服务接口。这个接口通常会遵循JAX-WS规范,定义服务的操作。例如: ```java import javax.jws....
一个用springboot搭建的简单的cxf实例,可以用于入门跟学习
SpringBoot与CXF WebService整合教程 在Java世界中,SpringBoot以其简洁的配置和快速的应用开发能力,已经成为主流的微服务框架。而CXF作为一款强大的SOAP和RESTful Web服务框架,使得开发者能够轻松地创建和消费...
而CXF则是一个开源服务框架,它支持多种Web服务标准,如SOAP和RESTful API,使得开发和部署Web服务变得简单。本教程将详细介绍如何在Spring Boot项目中集成CXF来发布Web服务接口。 首先,我们需要确保项目中包含了...
Spring Security可以与Spring CXF很好地集成,提供基于角色的访问控制和OAuth2支持。 8. **监控和日志**:为了监控服务性能和错误,我们可以配置Spring CXF的日志和跟踪功能,同时可以使用Spring Boot Actuator等...
SpringBoot与CXF整合创建Web服务 在现代的软件开发中,Web服务是实现系统间交互的重要手段。SpringBoot以其轻量级、快速启动和易于配置的特点,成为了开发微服务的首选框架。而Apache CXF则是一个强大的开源框架,...