通常,wsit client.xml的import语句如下所示:
<import location="foo.xml" namespace="http://foo.org/" />我发现它们可以在classpath/META-INF上的一个wsit client.xml中在线,但是我可以引用位于该wsit client.xml中的另一个jar中的xml吗?类似于:
<import location="classPathResource/WEB-INF/foo.xml" namespace="http://foo.org/" />我想创建一个wsit client.xml,它包含我所有who服务的导入,但我想将所有不同who服务的配置分离到不同的项目中。
发布于 2010-10-27 16:05:42
现在我可以定义location="myprotocol://foo.xml“,通过在wsit client.xml中创建URLStreamHandler来修复它
我使用了spring在另一个项目/ PathMatchingResourcePatternResolver中定位我的xml文件。
public class Handler extends URLStreamHandler {
@Override
protected URLConnection openConnection(URL u) throws IOException {
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
final URL resourceUrl = resolver.getResource(u.getPath()).getURL();
if (resourceUrl == null) {
throw new IOException(String.format("File %s not found on the classpath", u.getFile()));
}
return resourceUrl.openConnection();
}
}我没有使用VM参数来定义处理程序,但我实现了一个类似于这里解释的URL to load resources from the classpath in Java的URLStreamHandlerFActory
有关编写自己的协议处理程序的更多信息,请访问以下站点:http://java.sun.com/developer/onlineTraining/protocolhandlers/
我仍然有一个项目,它包含单个wsit client.xml,其中引用了我所有的web服务配置,但至少我已经设法将不同maven项目中所有不同服务的配置分开。
https://stackoverflow.com/questions/3987634
复制相似问题