Hi,
is there any way to control the package name of generated exception classes
when going WSDL to Java?
I have a schema file for common exceptions that looks like this:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xs:schema
attributeFormDefault="qualified"
elementFormDefault="qualified"
version="1.0"
xmlns:common-faults="urn:mycorp.com:common:faults:external:1.0.0"
targetNamespace="urn:mycorp.com:common:exceptions:external:1.0.0"
xmlns:tns="urn:mycorp.com:common:exceptions:external:1.0.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:import namespace="urn:mycorp.com:common:faults:external:1.0.0"
schemaLocation="common_faults_schema.xsd"/>
<xs:element name="ValidationException"
type="common-faults:ValidationFaultMessage"/>
</xs:schema>
The WSDL file for my webservice references this schema file:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions name="MailboxWebService"
targetNamespace="urn:mycorp.com:config:ws:external:mailbox:1.0.0"
xmlns:tns="urn:mycorp.com:config:ws:external:mailbox:1.0.0"
xmlns:common-exceptions="urn:mycorp.com:common:exceptions:external:1.0.0"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" >
<wsdl:types>
<xs:schema>
<xs:import
namespace="urn:mycorp.com:common:exceptions:external:1.0.0"
schemaLocation="http://localhost/xsd-pub/common/1.0.0/common_exceptions_schema.xsd"/>
</xs:schema>
</wsdl:types>
etc...
When compiling from WSDL to Java; I define the package name of all objects
in the common:exceptions schema to go to
com.mycorp.common.exceptions.external; i.e.:
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${cxf.version}</version>
<executions>
<execution>
<id>generateWebService</id>
<phase>process-resources</phase>
<configuration>
<sourceRoot>${project.build.directory}/generated/cxf</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>${project.build.outputDirectory}/MailboxWebService.wsdl</wsdl>
<extraargs>
<extraarg>-p</extraarg>
<extraarg>urn:mycorp.com:config:ws:external:mailbox:1.0.0=com.mycorp.config.ws.external.mailbox</extraarg>
<extraarg>-p</extraarg>
<extraarg>urn:mycorp.com:common:exceptions:external:1.0.0=com.mycorp.common.exceptions.external</extraarg>
<bindingFiles>
<bindingFile>${project.build.outputDirectory}/mailbox-binding.xml</bindingFile>
</bindingFiles>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-tools-wsdlto-databinding-jaxb</artifactId>
<version>${cxf.version}</version>
<exclusions>
<exclusion>
<groupId>xalan</groupId>
<artifactId>xalan</artifactId>
</exclusion>
<exclusion>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</plugin>
However, all this seems to do is put the ObjectFactory for the objects in
the common:exceptions schema in com.mycorp.common.exceptions.external; the
ACTUAL exception classes get generated in the same package my WebService is
in; i.e. com.mycorp.config.ws.external.mailbox.
This is a bit of a nuisance - we have a number of webservices in this
project; and they do have a common set of exceptions they throw (for example
ValidationException); but because each webservice essentially gets it's own
version of the exception class; we end up having to customize how some of
the underlying services throw those exceptions.
Any ideas?
Thanks!
--
View this message in context:
http://cxf.547215.n5.nabble.com/Controlling-the-package-name-of-generated-Exception-classes-tp5473458p5473458.html
Sent from the cxf-user mailing list archive at Nabble.com.