4

We're developing a quite big app with couple of dozens of service interfaces. For every service a wsdl is generated using wsgen (using the jaxws-maven-plugin maven plugin). For each service a different namespace is used in the wsdl's.

The service interfaces sharing a set of common beans (mostly DTOs). As now definitions for these common classes are defined in every wsdl's XSD duplicating a lot information, and this is causing problems for us on the client side (huge compilation times, class incompatibilities).

First I tried to create a schema for the common classes with schemagen but couldn't pass it to wsgen. Is there a way to pass one (or more) common XSD(s) into wsgen and have the generated wsdl(s) referencing to these?

I also tried to annotate the common classes with @XmlRootElement specifying a custom namespace: this time wsgen recognized the custom namespace and generated one more XSD for every wsdl but didn't included a single (common) xsd everywhere.

Could someone point me a solution for this problem?

marczeeee
  • 181
  • 1
  • 13

2 Answers2

0

I had a similar problem.

I added the annotation below to the common classes so they wouldn't be generated multiple times for each wsgen.

@XmlType(namespace = "http://mypackage.mycompany.com/")
public MyClass implements Serializable {
// ... class contents
}
gus3001
  • 851
  • 9
  • 19
0

You and I have a lot in common. :)

We do a lot of similar things: we have WSDL-first web services and DTOs used throughout our app. However, we define our DTOs with XML schemas so we could add metadata to them which adds code to the generated Java via JAXB plugins. We intended to use these XSD-based DTOs in our web services, but we were forced, by corporate standard, to use some common, corporate XSDs within our web services. It wouldn't have made a difference though - we could have just as easily used our DTO XSDs.

As to your issue, we have XSDs for our DTOs which you don't have. If you did then the only thing you'd need - assuming a Maven multi-module project is how to resolve the schemas across modules. We did this by forking the jaxws maven plugin and adding a CLASSPATH-based catalog schema resolver to it.

I suppose having you create schemas for your DTOs is out of the question? I can't help much beyond that as I've never used the jaxb annotations. Sorry.

tdrury
  • 2,307
  • 1
  • 22
  • 25