spring指定wsdl文件发布服务

  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不一致导致。

猜你喜欢

转载自ninnd.iteye.com/blog/1905171