我有两个用于不同服务的 WSDL 文件。两种服务都可以独立工作,但是如果我在同一个 eclipse 项目中包含这两种服务,我会收到以下错误的几个实例:
There's no ObjectFactory with an @XmlElementDecl for the element {http://schemas.foobar.com/oms/2010/10/Models}City.
this problem is related to the following location:
at protected javax.xml.bind.JAXBElement com.foobar.schemas.oms._2010._10.models.BusinessUnitData.city
at com.foobar.schemas.oms._2010._10.models.BusinessUnitData
at protected com.foobar.schemas.oms._2010._10.models.BusinessUnitData com.foobar.schemas.oms._2010._10.businessunit.CreateBusinessUnitRequest.businessUnitData
at com.foobar.schemas.oms._2010._10.businessunit.CreateBusinessUnitRequest
at @javax.xml.bind.annotation.XmlSeeAlso(value=[class com.foobar.schemas.oms._2010._10.businessunit.CreateBusinessUnitRequest])
at public com.foobar.schemas.oms._2010._10.businessunit.CCreateBusinessUnitRequest com.foobar.schemas.oms._2010._10.businessunit.ObjectFactory.createCCreateBusinessUnitRequest()
at com.foobar.schemas.oms._2010._10.businessunit.ObjectFactory
at protected javax.xml.bind.JAXBElement com.foobar.schemas.oms._2010._10.businessunit.AddToStructureRequest.unitStructureData
at com.foobar.schemas.oms._2010._10.businessunit.AddToStructureRequest
at @javax.xml.bind.annotation.XmlSeeAlso(value=[class com.foobar.schemas.oms._2010._10.businessunit.AddToStructureRequest])
There's no ObjectFactory with an @XmlElementDecl for the element {http://schemas.foobar.com/oms/2010/10/Models}ClientKey.
this problem is related to the following location:
at protected javax.xml.bind.JAXBElement com.foobar.schemas.oms._2010._10.models.BusinessUnitData.clientKey
at com.foobar.schemas.oms._2010._10.models.BusinessUnitData
at protected com.foobar.schemas.oms._2010._10.models.BusinessUnitData com.foobar.schemas.oms._2010._10.businessunit.CreateBusinessUnitRequest.businessUnitData
at com.foobar.schemas.oms._2010._10.businessunit.CreateBusinessUnitRequest
at @javax.xml.bind.annotation.XmlSeeAlso(value=[class com.foobar.schemas.oms._2010._10.businessunit.CreateBusinessUnitRequest])
at public com.foobar.schemas.oms._2010._10.businessunit.CCreateBusinessUnitRequest com.foobar.schemas.oms._2010._10.businessunit.ObjectFactory.createCCreateBusinessUnitRequest()
at com.foobar.schemas.oms._2010._10.businessunit.ObjectFactory
at protected javax.xml.bind.JAXBElement com.foobar.schemas.oms._2010._10.businessunit.AddToStructureRequest.unitStructureData
at com.foobar.schemas.oms._2010._10.businessunit.AddToStructureRequest
at @javax.xml.bind.annotation.XmlSeeAlso(value=[class com.foobar.schemas.oms._2010._10.businessunit.AddToStructureRequest])
这些错误完全填满了我的终端窗口,所以我不知道这种情况发生了多少次。
我正在以两种方式之一生成存根代码。首先,我尝试使用 wsdl2java 生成两者,然后将编译后的代码打包到一个 jar 中,并将其包含在我的构建路径中。我还尝试使用 cxf code-gen 插件创建一个新的 maven 项目。然后我运行“mvn install”并将生成的代码作为 maven 依赖项包含在内。两种技术产生相同的结果。每项服务都可以独立运行。但如果两者都包含在项目中,我会收到对象工厂错误。
是什么导致了这种类型的错误?可以用 jaxb 绑定文件修复吗?如果是这样,我是 web 服务的新手,并且一直无法找到示例绑定文件来学习如何格式化它。