Bootstrap

SpringBoot /Java 集成Webservice服务端

一、Maven依赖

 <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-frontend-jaxws</artifactId>
            <version>3.2.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-transports-http</artifactId>
            <version>3.2.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-core</artifactId>
            <version>3.3.5</version>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-transports-http</artifactId>
            <version>3.2.4</version>
        </dependency>

二、service类

@WebService(targetNamespace = "http://sso.demo.example.com/")
public interface SyncSinglePointJumpWebService {
    @WebMethod(operationName="syncSinglePointJumpWeb")
    public String syncSinglePointJumpWeb(@WebParam(name = "data",targetNamespace = "http://sso.demo.example.com/") String data);
}

三、serviceImpl实现类

@Component
@Service
@WebService(name = "SyncSinglePointJumpWebService", //与接口中指定的name一致
        targetNamespace = "http://sso.demo.example.com/", // // 与接口中的命名空间一致,一般是接口的包名倒
        endpointInterface = "com.example.demo.sso.SyncSinglePointJumpWebService")
public class SyncSinglePointJumpWebServiceImpl implements SyncSinglePointJumpWebService {
    @Override
    public String syncSinglePointJumpWeb(String data){
        return “测试”;
    }```

四、cxf服务端接口配置

@Configuration
public class CxfConfig {

    @Autowired
    private SyncSinglePointJumpWebService syncSinglePointJumpWebServiceImpl;

    @Bean
    public ServletRegistrationBean disServlet() {
        return new ServletRegistrationBean(new CXFServlet(), "/services/*");
    }
    @Bean(name = Bus.DEFAULT_BUS_ID)
    public SpringBus springBus() {
        return new SpringBus();
    }
    @Bean
    public Endpoint ocrWebService() {
        EndpointImpl endpoint = new EndpointImpl(springBus(), syncSinglePointJumpWebServiceImpl);
        endpoint.publish("/syncSinglePointJumpWeb");
        return endpoint;
    }

五、访问地址

http://ip:port/services?wsdl    //注:services为上一步CxfConfig配置的

demo下载地址:https://download.csdn.net/download/wqwq093030/86398444

;