英文:
JAXB Bindings for code generation using CXF
问题
我正在使用CXF代码生成插件和jaxb从WSDL生成Java存根。在绑定中,我已经指定了一个特定对象,在其中一个存根中,必须是一个String对象,即使XSD将其指定为整数。
绑定:
<jxb:bindings schemaLocation="../../../../../WSDL_Package/ABC/ABC_1.xsd">
<jxb:bindings node="//xs:complexType[@name='TypeI']//xs:sequence//xs:element[@name='number']">
<xjc:javaType name="java.lang.String" adapter="javax.xml.bind.annotation.adapters.XmlAdapter" />
</jxb:bindings>
</jxb:bindings>
但是在项目中使用这些存根时,我收到异常消息:
> 信息: 无法创建类javax.xml.bind.annotation.adapters.XmlAdapter的新实例
> java.lang.InstantiationException
有人能帮助解决这个问题吗?
英文:
I am generating Java stubs from a WSDL using CXF codegen plugin and jaxb. In the bindings, I have specified that one particular object in one of the stubs has to be a String object even though the XSD has specified it as an integer.
The binding:
<jxb:bindings schemaLocation="../../../../../WSDL_Package/ABC/ABC_1.xsd">
<jxb:bindings node="//xs:complexType[@name='TypeI']//xs:sequence//xs:element[@name='number']">
<xjc:javaType name="java.lang.String" adapter="javax.xml.bind.annotation.adapters.XmlAdapter" />
</jxb:bindings>
</jxb:bindings>
But on using the stubs in my project, I get the exception
> INFO: failed to create a new instance of class
> javax.xml.bind.annotation.adapters.XmlAdapter
> java.lang.InstantiationException
Can someone help with resolving this issue?
答案1
得分: 1
因为 javax.xml.bind.annotation.adapters.XmlAdapter
是一个抽象类,无法被实例化。您必须实现您的适配器。
public final class MyAdapter extends XmlAdapter<Type1,Type2> { ... }
英文:
Because javax.xml.bind.annotation.adapters.XmlAdapter
is an abstract class and cannot be instantiated. You must implement your adapter.
public final class MyAdapter extends XmlAdapter<Type1,Type2> { ... }
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论