From 51feab2d25ed865d744401f041f0709213a60926 Mon Sep 17 00:00:00 2001 From: psh Date: Wed, 21 Feb 2024 17:36:00 +0800 Subject: [PATCH] =?UTF-8?q?Webservice=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lms/nladmin-system/nlsso-server/pom.xml | 27 +++++++++ .../java/org/nl/wms/mes/domain/Public.java | 20 +++++++ .../nl/wms/mes/domain/QPMES060Request.java | 55 ++++++++++++++++++ .../nl/wms/mes/domain/QPMES060Response.java | 22 ++++++++ .../wms/mes/webservice/WebServiceConfig.java | 56 +++++++++++++++++++ .../webservice/service/QPMES060Service.java | 19 +++++++ .../service/impl/QPMES060ServiceImpl.java | 24 ++++++++ .../main/resources/config/application-dev.yml | 2 +- 8 files changed, 224 insertions(+), 1 deletion(-) create mode 100644 lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/mes/domain/Public.java create mode 100644 lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/mes/domain/QPMES060Request.java create mode 100644 lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/mes/domain/QPMES060Response.java create mode 100644 lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/mes/webservice/WebServiceConfig.java create mode 100644 lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/mes/webservice/service/QPMES060Service.java create mode 100644 lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/mes/webservice/service/impl/QPMES060ServiceImpl.java diff --git a/lms/nladmin-system/nlsso-server/pom.xml b/lms/nladmin-system/nlsso-server/pom.xml index 0074b37..e165db1 100644 --- a/lms/nladmin-system/nlsso-server/pom.xml +++ b/lms/nladmin-system/nlsso-server/pom.xml @@ -451,6 +451,33 @@ lucene-queryparser ${lucene.version} + + + org.springframework.boot + spring-boot-starter-web-services + + + + + org.apache.cxf + cxf-rt-frontend-jaxws + 3.2.0 + + + org.apache.cxf + cxf-rt-transports-http + 3.2.0 + + + org.apache.cxf + cxf-core + 3.3.5 + + + org.apache.cxf + cxf-rt-transports-http + 3.2.4 + diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/mes/domain/Public.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/mes/domain/Public.java new file mode 100644 index 0000000..715a997 --- /dev/null +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/mes/domain/Public.java @@ -0,0 +1,20 @@ +package org.nl.wms.mes.domain; + +import lombok.Data; + +@Data +public class Public { + // 接口名称 + private String INTF_ID; + // 源系统 + private String SRC_SYSTEM; + // 目标系统 + private String DEST_SYSTEM; + // 消息ID + private String SRC_MSGID; + // 控制预留1 + private String BACKUP1; + // 控制预留2 + private String BACKUP2; + +} diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/mes/domain/QPMES060Request.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/mes/domain/QPMES060Request.java new file mode 100644 index 0000000..765ca7a --- /dev/null +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/mes/domain/QPMES060Request.java @@ -0,0 +1,55 @@ +package org.nl.wms.mes.domain; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.ToString; +import lombok.experimental.Accessors; + +import javax.xml.bind.annotation.XmlRootElement; + +@Data +@ToString +@Builder +@NoArgsConstructor +@AllArgsConstructor +@XmlRootElement +@Accessors(chain = true) +public class QPMES060Request extends Public { + // 入库单号 + private String SimtOrderNo; + // 场地 + private String locationCode; + // 入库类型 + private String simtType; + // 到货单号 + private String deliveryNo; + // 扫描库位 + private String whlCode; + // 托盘号 + private String PalletSN; + // 物料条码号 + private String lotSN; + // 物料编码 + private String productName; + // 物料名称 + private String productDescription; + // 供应商编码 + private String supplierCode; + // 供应商名称 + private String supplierName; + // 规格 + private String specification; + // 批次号 + private String batch; + // 数量 + private String qty; + // 来料长度 + private String incomingLength; + // 来料重量 + private String incomingWeight; + // 来料缺陷长度 + private String incomingchipping; + +} diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/mes/domain/QPMES060Response.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/mes/domain/QPMES060Response.java new file mode 100644 index 0000000..e430aa0 --- /dev/null +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/mes/domain/QPMES060Response.java @@ -0,0 +1,22 @@ +package org.nl.wms.mes.domain; + +import lombok.Data; + +@Data +public class QPMES060Response extends Public { + // 消息状态 + private String STATUS; + // 消息文本 + private String MESSAGE; + // 预留主键1 + private String KEY_VALUE01; + // 预留主键2 + private String KEY_VALUE02; + // 预留主键3 + private String KEY_VALUE03; + // 预留主键4 + private String KEY_VALUE04; + // 预留主键5 + private String KEY_VALUE05; + +} diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/mes/webservice/WebServiceConfig.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/mes/webservice/WebServiceConfig.java new file mode 100644 index 0000000..8b73024 --- /dev/null +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/mes/webservice/WebServiceConfig.java @@ -0,0 +1,56 @@ +package org.nl.wms.mes.webservice; + +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.nl.wms.mes.webservice.service.QPMES060Service; +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 WebServiceConfig { + + @Autowired + private QPMES060Service qpmes060Service; + +// @Autowired +// private WebServiceAuthInterceptor interceptor; + + /** + * Apache CXF 核心架构是以BUS为核心,整合其他组件。 + * Bus是CXF的主干, 为共享资源提供一个可配置的场所,作用类似于Spring的ApplicationContext,这些共享资源包括 + * WSDl管理器、绑定工厂等。通过对BUS进行扩展,可以方便地容纳自己的资源,或者替换现有的资源。默认Bus实现基于Spring架构, + * 通过依赖注入,在运行时将组件串联起来。BusFactory负责Bus的创建。默认的BusFactory是SpringBusFactory,对应于默认 + * 的Bus实现。在构造过程中,SpringBusFactory会搜索META-INF/cxf(包含在 CXF 的jar中)下的所有bean配置文件。 + * 根据这些配置文件构建一个ApplicationContext。开发者也可以提供自己的配置文件来定制Bus。 + */ + @Bean(name = Bus.DEFAULT_BUS_ID) + public SpringBus springBus() { + return new SpringBus(); + } + + /** + * http://localhost:8010/webServices?wsdl + */ + @Bean + public ServletRegistrationBean getRegistrationBean() { + return new ServletRegistrationBean(new CXFServlet(), "/webServices/*"); + } + + /** + * http://localhost:8010/webServices/qpmes060?wsdl + */ + @Bean + public Endpoint messageEndPoint() { + EndpointImpl endpoint = new EndpointImpl(springBus(), qpmes060Service); + endpoint.publish("/qpmes060"); +// endpoint.getInInterceptors().add(this.interceptor); + return endpoint; + } + +} diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/mes/webservice/service/QPMES060Service.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/mes/webservice/service/QPMES060Service.java new file mode 100644 index 0000000..b658d1a --- /dev/null +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/mes/webservice/service/QPMES060Service.java @@ -0,0 +1,19 @@ +package org.nl.wms.mes.webservice.service; + +import org.nl.wms.mes.domain.QPMES060Request; +import org.nl.wms.mes.domain.QPMES060Response; + +import javax.jws.WebMethod; +import javax.jws.WebParam; +import javax.jws.WebService; +import java.util.List; + +@WebService( + name = "QPMES060", // 暴露服务名称 + targetNamespace = "http://127.0.0.1:8010"// 命名空间,一般是接口的包名倒序 +) +public interface QPMES060Service { + + @WebMethod(operationName = "notice") + public QPMES060Request QPMES060(@WebParam(name = "notice") QPMES060Response notice); +} diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/mes/webservice/service/impl/QPMES060ServiceImpl.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/mes/webservice/service/impl/QPMES060ServiceImpl.java new file mode 100644 index 0000000..bd3070c --- /dev/null +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/mes/webservice/service/impl/QPMES060ServiceImpl.java @@ -0,0 +1,24 @@ +package org.nl.wms.mes.webservice.service.impl; + +import org.nl.wms.mes.domain.QPMES060Request; +import org.nl.wms.mes.domain.QPMES060Response; +import org.nl.wms.mes.webservice.service.QPMES060Service; +import org.springframework.stereotype.Component; + +import javax.jws.WebService; + +@Component +@WebService( + name = "QPMES060", // 暴露服务名称 + targetNamespace = "http://127.0.0.1:8010", // 命名空间,一般是接口的包名倒序 + endpointInterface = "org.nl.wms.mes.webservice.service.QPMES060Service" // 接口类全路径 +) +public class QPMES060ServiceImpl implements QPMES060Service { + + @Override + public QPMES060Request QPMES060(QPMES060Response notice){ + + System.out.println("服务被调用 参数:" + notice.toString()); + return new QPMES060Request(); + } +} diff --git a/lms/nladmin-system/nlsso-server/src/main/resources/config/application-dev.yml b/lms/nladmin-system/nlsso-server/src/main/resources/config/application-dev.yml index 23ce6a2..454198c 100644 --- a/lms/nladmin-system/nlsso-server/src/main/resources/config/application-dev.yml +++ b/lms/nladmin-system/nlsso-server/src/main/resources/config/application-dev.yml @@ -160,4 +160,4 @@ sa-token: # Redis服务器连接密码(默认为空) password: # 连接超时时间 - timeout: 10s + timeout: 10s \ No newline at end of file