سؤال

I'm using a contract first approach to build JAX-WS Webservices. The clients pick the wsdl and xsd resources from a client jar as specified in this SO answer - https://stackoverflow.com/a/18323853/775467 by using the wsdlLocation attribute.

Is it possible to do the same on the server side. i.e is it possible to use wsdls and referred xsds from a jar in sun-jaxws.xml

<endpoint name='TestService'
        implementation='provider.server.AddNumbersImpl'
        wsdl='WEB-INF/wsdl/Test.wsdl'
        service='{http://example.org}TestService'
        port='{http://example.org}TestServicePort'
        url-pattern='/test'/>

I know that I can refer to wsdls in the WEB-INF directory as in the above snippet but I don't want to package the wsdls and xsds into the WAR but would like to pick them up from a shared library jar deployed to the server in the same way how the client code picks the wsdl.

هل كانت مفيدة؟

المحلول

There's no possibility to change the location of the wsdl file. The wsdl attribute at sun-jaxws.xml must have the prefix "WEB-INF/wsdl". Else JAX-WS generates and publishes a new WSDL. If you take a look at the source code of jaxws-ri, you can find the implementation at the class com.sun.xml.ws.transport.http.DeploymentDescriptorParser, method getPrimaryWSDL:

...
if (wsdlFile != null) {
        if (!wsdlFile.startsWith(JAXWS_WSDL_DD_DIR)) {
            logger.log(Level.WARNING, "Ignoring wrong wsdl={0}. It should start with {1}. Going to generate and publish a new WSDL.", new Object[]{wsdlFile, JAXWS_WSDL_DD_DIR});
            return null;
        }
...
}
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top