spring指定wsdl文件发布服务

本文介绍了一个关于WebService接口定义与实现过程中出现的ServiceConstructionException异常案例。该异常源于wsdl文件的targetNamespace与配置文件中tns属性值不一致。文章详细解释了如何创建WebService接口、实现接口、配置web.xml及bean,并生成wsdl文件。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  1. 创建接口类:
    @WebService(targetNamespace="http://service.sample.com/ws/")
    public interface Hello {
    	@WebMethod
    	public String sayHi(@WebParam(name="name") String name);
    }
  2. 实现接口 :
    @WebService(endpointInterface = "Hello")
    public class HelloImpl implements Hello {...}
     
  3.  配置web.xml: 略
  4. 生成wsdl文件:
    java2ws -o wsdl/hello.wsdl -wsdl Hello
     
  5. 配置bean:
    <jaxws:endpoint id="hello" xmlns:tns="http://service.sample.com/ws/"
    		implementor="HelloImpl"
    		endpointName="tns:helloPort"
    		serviceName="tns:helloService"
    		wsdlLocation="classpath:wsdl/hello.wsdl"
    		address="/hello" />
     
  6. 出现的异常:
    org.apache.cxf.service.factory.ServiceConstructionException: Could not find definition for service {
     我出现这种异常是wsdl文件的targetNamespace和配置的tns不一致导致。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值