如何将wsdlLocation设置为URL的WebService公告



我有一个WebService类:

@javax.jws.WebService(endpointInterface="Test",
    targetNamespace="http://www.test.com/test/",
    wsdlLocation="")
public class TestImpl implements Test{
  //...
}

然而,wsdlLocation只接受一个String,但我需要从资源URL获取wsdl文件:

url = getClass().getResource("/wsdl/Test.wsdl");

它被打包在一个jar文件中。如何在公告中正确设置wsdlLocation参数?

您不必在webService注释中使用wsdlLocation属性,这是可选的,您可以执行此

@javax.jws.WebService(endpointInterface="Test",
    targetNamespace="http://www.test.com/test/")
public class TestImpl implements Test{
  //...
}

在属性文件或其他文件中设置url,您可以在运行时在webService客户端中动态设置Web服务url(和WSDL url),并使用您喜欢的方法读取它,设置url的方式将取决于您使用的JAX-WS框架。

您可以使用类似的东西:

wsdlLocation = "file:../wsdl/Test.wsdl"

这将在项目文件中查找test.wsdl文件,您只需要正确指向该文件即可。

最新更新