springboot webservice接口一个配置文件配置两个接口路径

需求是我们的Java项目中需要和移动端对接接口 ,同时也需要和终端设备对接接口所以为了区分做了两个接口路径:
http://localhost:994/pbh/api app接口路径
http://localhost:994/pbh/terminal 终端接口路径

在配置文件中配置两套 Endpoint

package com.qckj.health.module.webService.config;


import com.qckj.health.module.webService.app.IPbhAppService;
import com.qckj.health.module.webService.app.PbhAppServiceImpl;
import com.qckj.health.module.webService.terminal.IPbhTerminalService;
import com.qckj.health.module.webService.terminal.IPbhTerminalServiceImpl;
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.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.xml.ws.Endpoint;

@Configuration
public class CxfConfig {

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

    @Bean(name = Bus.DEFAULT_BUS_ID)
    public SpringBus springBus() {
        return new SpringBus();
    }

    @Bean
    public IPbhAppService demoService() {
        return new PbhAppServiceImpl();
    }

    @Bean
    public IPbhTerminalService terminalService() {
        return new IPbhTerminalServiceImpl();
    }

    @Bean
    public Endpoint endpoint() {
        EndpointImpl endpoint = new EndpointImpl(springBus(), demoService());
        endpoint.publish("/api");
        return endpoint;
    }

    @Bean
    public Endpoint endpoint1() {
        EndpointImpl endpoint = new EndpointImpl(springBus(), terminalService());
        endpoint.publish("/terminal");
        return endpoint;
    }

}

IPbhTerminalService 接口

package com.qckj.health.module.webService.terminal;


import javax.jws.WebParam;
import javax.jws.WebService;

@WebService(name = "TerminalService", // 暴露服务名称
        targetNamespace = "http://app.webService.module.health.qckj.com"// 命名空间,一般是接口的包名倒序
)

public interface IPbhTerminalService {
    
    public String getDistListByDictType(@WebParam(name = "in0") String jsonStr);



 
    public String uploadTj_hebeilangfang(@WebParam(name = "in0") String jsonStr);


}

IPbhTerminalService 接口实现

package com.qckj.health.module.webService.terminal;


@WebService(serviceName = "TerminalService", // 与接口中指定的name一致
        targetNamespace = "http://terminal.webService.module.health.qckj.com", // 与接口中的命名空间一致,一般是接口的包名倒
        endpointInterface = "com.qckj.health.module.webService.terminal.IPbhTerminalService"// 接口地址
)
@Slf4j
public class IPbhTerminalServiceImpl implements IPbhTerminalService {
    @Autowired
    private UserService userService;
    @Autowired
    private QcTerminalUploadService qcTerminalUploadService;
    @Autowired
    private PhysicalUploadService physicalUploadService;


    @Override
    public String getDistListByDictType(String jsonStr) {
        Map<String, Object> map = (Map<String, Object>) GsonUtil.fromJson(jsonStr);
        return userService.getDistListByDictType(map);
    }
}


DemoService 接口

package com.qckj.health.module.webService.app;


import javax.jws.WebParam;
import javax.jws.WebService;

@WebService(name = "DemoService", // 暴露服务名称
        targetNamespace = "http://app.webService.module.health.qckj.com"// 命名空间,一般是接口的包名倒序
)

public interface IPbhAppService {

    public String checkBasicInfo(@WebParam(name = "in0") String idcard);


    public String uploadData(@WebParam(name = "in0") String type, @WebParam(name = "in1") String jsonStr1, @WebParam(name = "in2") String jsonStr2, @WebParam(name = "in3") String reservedPara1, @WebParam(name = "in4") String reservedPara2) throws Exception;


    public String uploadManageData(@WebParam(name = "in0") String type, @WebParam(name = "in1") String jsonStr1, @WebParam(name = "in2") String reservedPara1, @WebParam(name = "in3") String reservedPara2) throws Exception;

    public String uploadBasicInfo(@WebParam(name = "in0") String jsonStr1, @WebParam(name = "in1") String jsonStr2, @WebParam(name = "in2") String jsonStr3, @WebParam(name = "in3") String jsonStr4, @WebParam(name = "in4") String reservedPara1, @WebParam(name = "in5") String reservedPara2) throws Exception;



}

DemoService 接口实现

package com.qckj.health.module.webService.app;


@WebService(serviceName = "DemoService", // 与接口中指定的name一致
        targetNamespace = "http://app.webService.module.health.qckj.com", // 与接口中的命名空间一致,一般是接口的包名倒
        endpointInterface = "com.qckj.health.module.webService.app.IPbhAppService"// 接口地址
)

public class PbhAppServiceImpl implements IPbhAppService {
}
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值