首页 新闻 赞助 找找看

今天在使用spring boot框架使用webservice时遇到这样一个问题

0
悬赏园豆:10 [待解决问题]

自己写完一个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文档的。可是现在输完地址浏览器没有任何反应。不知道问题出在了哪里。

 

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

gaoxuechaochao的主页 gaoxuechaochao | 初学一级 | 园豆:188
提问于:2016-12-01 10:25
< >
分享
所有回答(2)
0

这样访问:http://localhost:8080/webservice/soap/user?wsdl就可以了;也就是说是:http://localhost:8080/项目名称/soap/user?wsdl,“webservice”是我的名称,你换成你你的就可以了,附图片

nowitzki41 | 园豆:202 (菜鸟二级) | 2017-01-13 14:09

如果不发布在8080端口,怎么设置呢?

支持(0) 反对(0) 神经衰弱helloworld | 园豆:42 (初学一级) | 2019-01-17 16:54
0

 同上,一楼应该是正解

Mr_伍先生 | 园豆:6 (初学一级) | 2017-06-04 21:14
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册