Hi Daniel, I've put together a little test case. If you download the zip archive at this link:
http://dl.dropbox.com/u/24296192/JAXWSExample.zip You will find two maven projects inside. The first one, jaxws-example-model, contains a simple Java POJO called "Message". The project contains the necessary JAXWS annotations to control how the schema for this object gets generated; and it specifies the location of an external schema file; like so: @XmlSchema(namespace="urn:ws.example.com:model", location="http://localhost:8080/jaxws-example-ws/xsd/example.xsd") package com.example.model; import javax.xml.bind.annotation.XmlSchema; Note that the POM file of the project has the JAXB plugin so that the schema file can be re-generated if required (although that would require removing the location attribute from the @XmlSchema annotation again; as JAXB will ignore any packages that have that). The second project, jaxws-example-ws, is the actual webservice. It has a dependency on jaxws-example-data; so you will have to run a mvn install on that project first in order for compilation to work. The webservice is rigged up in the src/main/resources/spring/appContext.xml file; like so: <jaxws:endpoint id="exampleWebService" implementor="#exampleService" implementorClass="com.example.ws.ExampleWebServiceImpl" address="/ExampleService" > I'm also using the cxf-java2ws-plugin in the POM file to generate a static WSDL file at /src/main/wsdl/ExampleWebService.wsdl. This WSDL is identical to the one generated on the fly by CXF if you start the application; so in both cases the behavior is similar. If you look at the WSDL; you'll see that the urn:ws.example.com:model schema is imported; but no schemaLocation is specified; which results in a malformed WSDL. I guess I should have also explained what I'm actually trying to do. Our company is implementing a full SOA approach; including the use of ESBs and WS-BPEL. As we're offering a full fledged API to our customers; we're finding that a lot of our webservices re-use the same underlying domain objects. We don't want each webservice have it's own embedded schema definitions for these domain objects; because, among other things, it causes problems when using BPEL. So the idea was to have a foundation of schema's describing domain objects (users, accounts, etc, etc) and then having the various webservice wsdls reference those. With a contract-first approach, this is of course perfectly possible; and that's in fact what we're doing right now. But given number of webservice operations we're implementing, WSDL first is turning out to be quite cumbersome and time-consuming. A Java-first approach would allow us to roll out webservices quicker; while retaining full control over the form of the generated WSDL by using the JAXWS annotations. It's still a less than ideal situation; as you can see - we need to remove the location attribute from the XMLSchema annotation to have JAXB generate the external schema; then add it back in to avoid having the cxf-java2ws-plugin generate the schema when the WSDL is generated; but it's workable. I suppose the ultimate solution would be something similar to what's possible with the wsdl2java plugin and the -nexclude argument that can be added into the WSDLOption of the plugin... if we could somehow tell the cxf-java2ws-plugin that when it encounters the schema urn:com.example.model, it should NOT generate a schema in the WSDL but instead import an external schema at http://localhost/jaxws-example-ws/xsd/example.xsd; that would really be the perfect solution; i.e something like: <plugin> <groupId>org.apache.cxf</groupId> <artifactId>cxf-java2ws-plugin</artifactId> <version>${cxf.version}</version> <dependencies> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-frontend-jaxws</artifactId> <version>${cxf.version}</version> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-frontend-simple</artifactId> <version>${cxf.version}</version> </dependency> </dependencies> <executions> <execution> <id>process-classes</id> <phase>process-classes</phase> <configuration> <className>com.example.ws.ExampleWebService</className> <genWsdl>true</genWsdl> <verbose>true</verbose> <outputFile>${basedir}/src/main/wsdl/ExampleWebService.wsdl</outputFile> *<extraargs> <extraarg>-nexclude</extraarg> <extraarg>urn:ws.example.com:model=http://localhost/jaxws-example-ws/xsd/example.xsd</extraarg> </extraargs>* </configuration> <goals> <goal>java2ws</goal> </goals> </execution> </executions> </plugin> But I don't know how hard that is to implement.... -- View this message in context: http://cxf.547215.n5.nabble.com/CXF-java2wsdl-plugin-not-importing-external-schema-defined-in-XmlSchema-annotation-tp5135016p5149809.html Sent from the cxf-user mailing list archive at Nabble.com.