views:

17

answers:

1

Normally the wsit-client.xml has import statements like this:

<import location="foo.xml" namespace="http://foo.org/" />

I've found that their can be online one wsit-client.xml on the classpath/META-INF, but can I refer to an xml who's located into another jar in that wsit-client.xml? Something like :

<import location="classPathResource/WEB-INF/foo.xml" namespace="http://foo.org/" />

I would like to create a single wsit-client.xml who contains the imports for all my webservices but I want to separate the configuration for all the different webservices in to different projects.

A: 

I've fixed it by creating an URLStreamHandler in the wsit-client.xml I can now define location="myprotocol://foo.xml"

I've used spring's PathMatchingResourcePatternResolver to locate my xml file in another project/jar.

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();
}
}

I'm not using the VM arguments to define the handler but I've implemented an URLStreamHandlerFActory like explained over here http://stackoverflow.com/questions/861500/url-to-load-resources-from-the-classpath-in-java

More info about writing your own protocol handlers can be find on this site: http://java.sun.com/developer/onlineTraining/protocolhandlers/

I've still got 1 project who contains the single wsit-client.xml with references to all my web service configurations, but at least I've managed to separate the configuration for all the different services in different maven projects.

Stijn Vanpoucke