简体   繁体   中英

Avoid creation of JDK classes in Apache CXF wsdl2java task

I have a WSDL file with defines a java.io.Exception:

<xsd:schema xmlns:tns="http://io.java" xmlns:xsd="http://www.w3.org/2001/XMLSchema" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://io.java">
<xsd:complexType name="IOException">
<xsd:sequence/>
    </xsd:complexType>
</xsd:schema>

When generating Java classes using the Apache CXf wsdl2java task, it generates a class like this (which causes compile errors, as it is not a valid java.io.IoException):

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "IOException")
public class IOException {
}

Is there a way to prevent CXF from generating JDK classes?

Thx! :)

You definitely need to change your namespace.

targetNamespace="http://io.java"
xmlns:tns="http://io.java"

If you have such namespace and the complex type named IOException of course there will a problem. And why in the world you named the namespace like this http://io.java ?

Change the namespace for eg:

targetNamespace="http://yourcompany.com/yourservice"
xmlns:tns="http://yourcompany.com/yourservice"

You you'll be good.

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