Spring boot 中使用webservice

自己写完一个demo后,测试时得不到wsdl文档,下面贴上自己的代码

首先是发布服务用的接口
package com.pudding.tcs.ctrip.testservice;
import javax.jws.WebMethod;
import javax.jws.WebService;
@WebService
public interface TestService {
@WebMethod
public String test(String param);
}

接下来是接口实现
package com.pudding.tcs.ctrip.testservice;
public class TestServiceImpl implements TestService {
@Override
public String test(String param) {
return "param="+param;
}
}
再接下来是配置类用于发布服务:
package com.pudding.tcs.ctrip.config;
import javax.xml.ws.Endpoint;
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.context.embedded.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.pudding.tcs.ctrip.testservice.TestService;
import com.pudding.tcs.ctrip.testservice.TestServiceImpl;
@Configuration
public class TestConfig {
@Bean
public ServletRegistrationBean dispatcherServlet() {
return new ServletRegistrationBean(new CXFServlet(), "/soap/*");
}

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

@Bean
public TestService testService() {
return new TestServiceImpl();
}

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

}
按道理讲这样配置完之后我启动服务器,在地址栏输入http://localhost:8080/soap/test?wsdl是可以显示wsdl文档的。可是现在输完地址浏览器没有任何反应。不知道问题出在了哪里。

还望各路神仙给小弟解答一下

猜你喜欢

转载自blog.csdn.net/qq_35192741/article/details/82628378