我正在使用jaxb从xml架构生成java类.模式导入XMLSchema.xsd,其内容用作文档中的元素.
如果我分别删除导入和对"xsd:schema"的引用,那么绑定编译器会成功生成类.如果我没有那么它会产生以下错误,如果我尝试仅从XMLSchema.xsd生成Java类,则会出现同样的错误!
> C:\Users\me>"%JAXB%/xjc" -extension -d tmp/uisocketdesc -p uis.jaxb uisocketdesc.xsd -b xml_binding_test.xml -b xml_binding_test_2.xml
-b xml_binding_test_3.xml
parsing a schema...
compiling a schema...
> [ERROR] A class/interface with the same name "uis.jaxb.ComplexType" is already in use. Use a class customization to resolve this conflict.
line 612 of "http://www.w3.org/2001/XMLSchema.xsd"
> [ERROR] (Relevant to above error) another "ComplexType" is generated from here.
line 440 of "http://www.w3.org/2001/XMLSchema.xsd"
> [ERROR] A class/interface with the same name "uis.jaxb.Attribute" is already in use. Use a class customization …Run Code Online (Sandbox Code Playgroud) 我使用以下代码来解析soap响应,但我收到UnmarshallingFailureException,我将@XmlSeeAlso更改为@XMLRootElement但问题仍然存在.WSDL就在这里.
Caused by: javax.xml.bind.UnmarshalException: unexpected element
(uri:"ElsyArres.API", local:"SearchFlightsResponse"). Expected elements are
<{ElsyArres.API}Inbound>,<{ElsyArres.API}Leg>,<{ElsyArres.API}Legs>,
<{ElsyArres.API}Outbound>,<{ElsyArres.API}Request>,<{ElsyArres.API}Response>,
<{ElsyArres.API}SearchFlights>,<{ElsyArres.API}SoapMessage>
Run Code Online (Sandbox Code Playgroud)
码
@XmlRootElement(name = "SoapMessage")
@XmlAccessorType(XmlAccessType.FIELD)
public class WegoloSoapMessageResponse {
@XmlElement(name = "Username")
private String username;
@XmlElement(name = "Password")
private String password;
@XmlElement(name = "LanguageCode")
private String languageCode;
@XmlElement(name = "ErrorMessage")
private String errorMessage;
@XmlElement(name = "ErrorCode")
private int errorCode;
@XmlElement(name = "AppVersion")
private String appVersion;
@XmlElement(name = "Request")
private Request request;
@XmlElement(name = "Response")
private Response response;
getters and setters
@XmlRootElement(name = "Request")
@XmlAccessorType(XmlAccessType.FIELD) …Run Code Online (Sandbox Code Playgroud) 当我xjc -d src/ -p com.test IFC2X3.xsd在下面的xsd上运行命令时,它会产生冲突.
....
<xs:element name="IfcCondenserTypeEnum" nillable="true">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="ifc:IfcCondenserTypeEnum">
<xs:attributeGroup ref="ex:instanceAttributes">
</xs:attributeGroup>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:simpleType name="IfcCondenserTypeEnum">
<xs:restriction base="xs:string">
<xs:enumeration value="watercooledshelltube">
</xs:enumeration>
<xs:enumeration value="watercooledshellcoil">
</xs:enumeration>
<xs:enumeration value="watercooledtubeintube">
</xs:enumeration>
<xs:enumeration value="watercooledbrazedplate">
</xs:enumeration>
<xs:enumeration value="aircooled">
</xs:enumeration>
<xs:enumeration value="evaporativecooled">
</xs:enumeration>
<xs:enumeration value="userdefined">
</xs:enumeration>
<xs:enumeration value="notdefined">
</xs:enumeration>
</xs:restriction>
</xs:simpleType>
....
Run Code Online (Sandbox Code Playgroud)
错误:
parsing a schema...
compiling a schema...
[ERROR] A class/interface with the same name "com.test.IfcCondenserTypeEnum" is already in use. Use a class customization to resolve this …Run Code Online (Sandbox Code Playgroud)