简体   繁体   中英

JAXB / xjc generated Exception classes are not Throwable

I am using jaxb-xjc (version 2.2.4-1, in a Gradle task) to generate Java classes from wsdl (to be used as a web service client).

According to wsdl documentation, some of the endpoints may throw custom exceptions.

The generated code looks fine, except for one detail: The generated exception classes do not extend Throwable (or any other class that would extend it). WSDL seems to be ok, as there is a fault element named in these endpoints (example):

<wsdl:fault name="IdentityNotFoundException" message="work_v2:IdentityNotFoundException"/>

Is there a way to configure xjc to make these custom Exception classes to be "real" exception classes? Current Gradle/xjc task configuration is:

            xjc(destdir: sourcesDir, schema: "src/main/resources/wsdl/workService_v2.wsdl",
                package: "workService.generated") {
            arg(value: "-wsdl")
            produces(dir: sourcesDir, includes: "**/*.java")
        }

Figured a workaround for this:

Instead of using xjc, I used another generator instead: wsdl2java

And surprise - The newly generated classes now extend Exception class! The Gradle settings used for wsdl2java were according to the example in its Github page.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM