CXF 를 사용 하여 웹 서비스 서버 만 들 기

1,의존 추가

    org.apache.cxf
    cxf-spring-boot-starter-jaxws
    3.2.7

2.웹 서 비 스 를 정의 하 는 인터페이스
package com.ultrapower.ioss.projectsign.service;

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

@WebService
public interface ProjectSignService {
    @WebMethod
    String sendResInfo(@WebParam(name = "serSupplier") String serSupplier,
            @WebParam(name = "serCaller") String serCaller,
            @WebParam(name = "callerPwd") String callerPwd,
            @WebParam(name = "callTime") String callTime,
            @WebParam(name = "opDetail") String opDetail);
}

3.인터페이스의 실현 완성
package com.ultrapower.ioss.projectsign.service.defaults;

import javax.jws.WebService;

import org.springframework.beans.factory.annotation.Autowired;

import com.ultrapower.ioss.projectsign.service.ProjectSignService;

/**
 *     :           targetNamespace                (PS:     ),
 * endpointInterface            ;@WebService(targetNamespace="http://service.webservicedemo.dbgo.com/",
 * endpointInterface = "com.dbgo.webservicedemo.service.UserService")
 * */
@WebService(targetNamespace="http://service.projectsign.ioss.ultrapower.com/",
endpointInterface = "com.ultrapower.ioss.projectsign.service.ProjectSignService")
public class ProjectSignWebService implements ProjectSignService {

    @Override
    public String sendResInfo(String serSupplier, String serCaller, String callerPwd, String callTime,
            String opDetail) {

        return "success";
    }

}

4,설정 추가
/**
 * http://localhost:8080/services/project?wsdl
 */
@Configuration
public class WebServiceConfig {

    @Autowired
    private Bus bus;

    @Bean
    public Endpoint endpoint() {
        EndpointImpl endpoint = new EndpointImpl(bus, projectSignService());
        endpoint.publish("/project");
        // endpoint.getInInterceptors().add(new LoggingInInterceptor());
        // endpoint.getOutInterceptors().add(new LoggingOutInterceptor());
        Swagger2Feature feature = new Swagger2Feature();
        feature.setBasePath("/ws");
        feature.setSupportSwaggerUi(true);
        endpoint.setFeatures(Arrays.asList(new Feature[] { feature }));
        return endpoint;
    }

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

    @Bean
    public ProjectSignService projectSignService() {
        return new ProjectSignWebService();
    }
}

좋은 웹페이지 즐겨찾기