快捷搜索:  汽车  科技

后台管理系统spring boot,SAP调用springboot发布的WebService接口地址

后台管理系统spring boot,SAP调用springboot发布的WebService接口地址package com.config; import com.service.impl.BalanceServiceImpl; import com.service.webservice.BalanceService; 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.boot.web.server.ConfigurableWebServerFactory; import org.springframework.boot.web.server.WebSer

前言:最近应公司与第三方的合作,需将数据推送至第三方的中间库供对方使用,而对方未提供任何数据调用地址,只提供了个中间库表样,这样一来,就只能自已发布个webService服务,然后在SAP端进行调用。

第一步:先开发SAP端报表取数接口

调用wsdl地址传输数据的主要代ABAP代码

FORM downlond_erp. ******* 定义接口对象 DATA:lo_proxy TYPE REF TO zfico_co_balance_service "实例化类对象 lo_input TYPE zfico_query_save_balance1 "输入参数 lo_items TYPE zfico_balance_dto lo_output TYPE zfico_query_save_balance_resp2 "输出参数 lo_sys_exception TYPE REF TO cx_ai_system_fault. DATA:meg TYPE string. CREATE OBJECT lo_proxy EXPORTING logical_port_name = 'ZFICO_CO_BALANCE_SERVICE'."调用逻辑端口 LOOP AT lt_table INTO ls_table WHERE sel = 'X'. TRY . lo_items-auxiliaryitemname = ls_table-name1. lo_items-auxiliaryitemnumber = ls_table-zffhsbm. lo_items-auxiliarytype = ls_table-zffhslx. lo_items-balancecreditvalue = ls_table-zqmyedf. lo_items-balancededitvalue = ls_table-zqmyejf. APPEND lo_items TO lo_input-parameters-balance_dto_list. CALL METHOD lo_proxy->query_save_balance EXPORTING query_save_balance = lo_input IMPORTING query_save_balance_response = lo_output. CLEAR:lo_input-parameters-balance_dto_list. CATCH cx_ai_system_fault INTO lo_sys_exception. WRITE: lo_sys_exception->errortext. ENDTRY. IF meg IS INITIAL. ls_table-zmsg = '下传成功'. MODIFY lt_table FROM ls_table. ELSE. ls_table-zmsg = meg. MODIFY lt_table FROM ls_table. ENDIF. ENDLOOP. ENDFORM.

第二步:搭建springboot环境

1.1 使用cxf发布wsdl地址两个主要依赖环境

<!-- cxf-spring-boot-starter-jaxrs --> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-spring-boot-starter-jaxrs</artifactId> <version>${cxf.version}</version> </dependency> <!-- cxf-rt-frontend-jaxws --> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-frontend-jaxws</artifactId> <version>${cxf.version}</version> </dependency>

1.2 创建一个interface 接口

package com.service.webservice; import com.dto.BalanceDto; import com.vo.AjaxResult; import javax.jws.WebMethod; import javax.jws.WebParam; import javax.jws.WebService; import java.util.List; /** * @author * @date 2021-12-04 **/ @WebService(name = "BalanceService" targetNamespace = "http://webservice.service.com/") public interface BalanceService { //注意 action 属性需加上 不然发布后的wsdl地址中 soapAption会为空,SAP调用会报错 @WebMethod(action = "http://webservice.service.com/service/querySaveBalance") public AjaxResult querySaveBalance(@WebParam(name = "balanceDtoList") List<BalanceDto> balanceDtoList); boolean selectBalanceById(String ztCode String subjectCode); }

1.3 创建接口实现类

package com.service.impl; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.date.DateUtil; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.domain.Balance; import com.dto.BalanceDto; import com.mapper.BalanceMapper; import com.service.webservice.BalanceService; import com.vo.AjaxResult; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import javax.jws.WebService; import java.math.BigDecimal; import java.util.HashMap; import java.util.List; import java.util.Map; /** * @author * @date 2021-12-04 **/ @WebService(endpointInterface = "com.jzj.service.webservice.BalanceService" targetNamespace = "http://jzj.cn/service/" serviceName = "BalanceService") public class BalanceServiceImpl implements BalanceService { @Autowired private BalanceMapper balanceMapper; /** *AjaxResult 这个可自定义返回类型 * balanceDtoList 使用集合接收数据 **/ @Override public AjaxResult querySaveBalance(List<BalanceDto> balanceDtoList) { //根据需求实现业务代码 return AjaxResult.success(map); } @Override public boolean selectBalanceById(String ztCode String subjectCode) { Balance balance = this.balanceMapper.selectBalanceById(ztCode subjectCode); if (null!=balance){ return true; }else { return false; } } }

1.4 创建CXF配置类

package com.config; import com.service.impl.BalanceServiceImpl; import com.service.webservice.BalanceService; 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.boot.web.server.ConfigurableWebServerFactory; import org.springframework.boot.web.server.WebServerFactoryCustomizer; import org.springframework.boot.web.servlet.ServletRegistrationBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import javax.xml.ws.Endpoint; /** * @author * @date 2021-12-03 **/ @Configuration public class CxfConfig { @Bean(name = "cxfServlet") public ServletRegistrationBean dispatcherServlet(){ return new ServletRegistrationBean(new CXFServlet() "/webServer/*"); } @Bean(name = Bus.DEFAULT_BUS_ID) public SpringBus springBus() { return new SpringBus(); } @Bean public BalanceService balanceService(){ return new BalanceServiceImpl(); } @Bean public Endpoint endpoint(){ EndpointImpl endpoint = new EndpointImpl(springBus() balanceService()); endpoint.publish("/soap/services/sap_webserver/webServer");//访问路径 return endpoint; } @Bean public WebServerFactoryCustomizer<ConfigurableWebServerFactory> webServerFactoryCustomizer() { return new WebServerFactoryCustomizer<ConfigurableWebServerFactory>(){ @Override public void customize(ConfigurableWebServerFactory factory) { factory.setPort(8081);//设置端口 } }; } }

1.5 启动springboot 项目 在浏览器地址输入:

http://ip:8081/soap/services/sap_webserver/webServer?wsdl

后台管理系统spring boot,SAP调用springboot发布的WebService接口地址(1)

后台管理系统spring boot,SAP调用springboot发布的WebService接口地址(2)

出现此界面时,说明wsdl地址发布成功,现在就可以去SAP端调用。

第三步:在SAP端创建代理类。

SE80——企业服务——右健点击 "ServiceConsumers"——”创建“

后台管理系统spring boot,SAP调用springboot发布的WebService接口地址(3)

后台管理系统spring boot,SAP调用springboot发布的WebService接口地址(4)

​​

后台管理系统spring boot,SAP调用springboot发布的WebService接口地址(5)

后台管理系统spring boot,SAP调用springboot发布的WebService接口地址(6)

​​

后台管理系统spring boot,SAP调用springboot发布的WebService接口地址(7)

后台管理系统spring boot,SAP调用springboot发布的WebService接口地址(8)

后台管理系统spring boot,SAP调用springboot发布的WebService接口地址(9)

​在SAP左上角输入:SOAMANAGER 打开web配置登录界面,如果打不开,请先配置本地的HOST文件​​

后台管理系统spring boot,SAP调用springboot发布的WebService接口地址(10)

后台管理系统spring boot,SAP调用springboot发布的WebService接口地址(11)

​​​

后台管理系统spring boot,SAP调用springboot发布的WebService接口地址(12)

后台管理系统spring boot,SAP调用springboot发布的WebService接口地址(13)

​​​

后台管理系统spring boot,SAP调用springboot发布的WebService接口地址(14)

后台管理系统spring boot,SAP调用springboot发布的WebService接口地址(15)

搜索代理类名称

​​​

后台管理系统spring boot,SAP调用springboot发布的WebService接口地址(16)

后台管理系统spring boot,SAP调用springboot发布的WebService接口地址(17)

​​点 创建 按钮——基于WSDL的配置

后台管理系统spring boot,SAP调用springboot发布的WebService接口地址(18)

后台管理系统spring boot,SAP调用springboot发布的WebService接口地址(19)

​​到这,SAP调用WSDL地址就能进行数据传输了。

创作不易,如果对你有用,请给我个赞,你的赞是我发布交流技术的动力。欢迎一起学习,一起交流,一起写bug。

猜您喜欢: