From dc20ae7801a3bda5e2110fcdb4961a822cc14728 Mon Sep 17 00:00:00 2001 From: "453530270@qq.com" Date: Wed, 31 Jul 2024 15:57:17 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=88=9D=E5=A7=8B=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 20 +++++++++ .../java/com/xtt/zls/config/WSConfig.java | 44 +++++++++++++++++++ .../java/com/xtt/zls/service/AppService.java | 19 ++++++++ .../xtt/zls/service/impl/AppServiceImpl.java | 36 +++++++++++++++ src/main/resources/application.properties | 1 + 5 files changed, 120 insertions(+) create mode 100644 src/main/java/com/xtt/zls/config/WSConfig.java create mode 100644 src/main/java/com/xtt/zls/service/AppService.java create mode 100644 src/main/java/com/xtt/zls/service/impl/AppServiceImpl.java diff --git a/pom.xml b/pom.xml index c6e4a19..4baa747 100644 --- a/pom.xml +++ b/pom.xml @@ -23,6 +23,26 @@ spring-boot-starter-web-services + + org.apache.cxf + cxf-spring-boot-starter-jaxws + 3.2.4 + + + + com.alibaba + fastjson + 2.0.7 + + + + + org.hibernate.validator + hibernate-validator + 6.1.5.Final + + + org.springframework.boot spring-boot-starter-test diff --git a/src/main/java/com/xtt/zls/config/WSConfig.java b/src/main/java/com/xtt/zls/config/WSConfig.java new file mode 100644 index 0000000..a83a90f --- /dev/null +++ b/src/main/java/com/xtt/zls/config/WSConfig.java @@ -0,0 +1,44 @@ +package com.xtt.zls.config; + + +import com.xtt.zls.service.AppService; +import org.apache.cxf.Bus; +import org.apache.cxf.bus.spring.SpringBus; +import org.apache.cxf.jaxws.EndpointImpl; +import org.apache.cxf.transport.servlet.CXFServlet; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.web.servlet.ServletRegistrationBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import javax.xml.ws.Endpoint; + +@Configuration +public class WSConfig { + + @Autowired + private AppService appService; + + + //默认servlet路径/*,如果覆写则按照自己定义的来 + @Bean + public ServletRegistrationBean cxfServlet() { + return new ServletRegistrationBean(new CXFServlet(), + "/webservice/*"); + } + + + @Bean(name = Bus.DEFAULT_BUS_ID) + public SpringBus springBus() { + return new SpringBus(); + } + + + //终端路径 + @Bean + public Endpoint endpoint() { + EndpointImpl endpoint = new EndpointImpl(springBus(), appService); + endpoint.publish("/test"); + return endpoint; + } +} \ No newline at end of file diff --git a/src/main/java/com/xtt/zls/service/AppService.java b/src/main/java/com/xtt/zls/service/AppService.java new file mode 100644 index 0000000..af7a811 --- /dev/null +++ b/src/main/java/com/xtt/zls/service/AppService.java @@ -0,0 +1,19 @@ +package com.xtt.zls.service; + +import javax.jws.WebMethod; +import javax.jws.WebParam; +import javax.jws.WebService; + +@WebService(name = "AppService", // 暴露服务名称 + targetNamespace = "http://tongtong.com"// 命名空间,一般是接口的包名倒序 +) +public interface AppService { + + @WebMethod + String casePaces(@WebParam(name = "map") String maps); + + @WebMethod + String getPlKt(@WebParam(name = "map") String map); + + +} \ No newline at end of file diff --git a/src/main/java/com/xtt/zls/service/impl/AppServiceImpl.java b/src/main/java/com/xtt/zls/service/impl/AppServiceImpl.java new file mode 100644 index 0000000..e15d2fc --- /dev/null +++ b/src/main/java/com/xtt/zls/service/impl/AppServiceImpl.java @@ -0,0 +1,36 @@ +package com.xtt.zls.service.impl; + +import com.xtt.zls.service.AppService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +import javax.annotation.PostConstruct; +import javax.jws.WebService; + + +@WebService(serviceName = "AppService", // 与接口中指定的name一致 + targetNamespace = "http://tongtong.com", // 与接口中的命名空间一致,一般是接口的包名倒 + endpointInterface = "com.xtt.zls.service.AppService"// 接口地址 +) +@Component +public class AppServiceImpl implements AppService { + + private Logger logger = LoggerFactory.getLogger(AppServiceImpl.class); + + @PostConstruct + private void init() { + + } + + @Override + public String casePaces(String maps) { + // + return ""; + } + + @Override + public String getPlKt(String maps) { + return ""; + } +} \ No newline at end of file diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index e52b498..70b4e6d 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,3 +1,4 @@ # 应用服务 WEB 访问端口 server.port=8080 +cxf.path=/soap \ No newline at end of file