Apache CXF 2.2.7 Spring 3 Web 服务解组错误:意外元素

2024-01-03

我使用 Apache CXF 2.2.7 和 Spring 3 开发了一个简单的 Web 服务应用程序,并将其作为 WAR 文件部署到 Tomcat 上,但收到以下错误消息:

2010 年 4 月 12 日 15:56:12 org.apache.cxf.phase.PhaseInterceptorChain doDefaultLogging 警告:拦截器 {http://services.aristabi.com/ http://services.aristabi.com/}ReportingServiceImplService#{http://services.aristabi.com/ http://services.aristabi.com/}getNewBusinessVolumeByCreateDate_v2 已引发异常,现在展开 org.apache.cxf.interceptor.Fault:解组错误:意外元素(uri:”http://services.aristabi.com/ http://services.aristabi.com/", local:"searchCriteria")。预期元素为 在org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:764) 在org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:623) 在org.apache.cxf.jaxb.io.DataReaderImpl.read(DataReaderImpl.java:128) 在 org.apache.cxf.interceptor.DocLiteralInInterceptor.handleMessage(DocLiteralInInterceptor.java:106) 在org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:243) 在 org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:109) 在 org.apache.cxf.transport.servlet.ServletDestination.invoke(ServletDestination.java:98) 在 org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:406) 在 org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:178) 在org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFServlet.java:142) 在 org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:179) 在 org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:103) 在 javax.servlet.http.HttpServlet.service(HttpServlet.java:637) 在 org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:159) 在 org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) 在 org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 在org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) 在org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) 在 org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) 在 org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) 在 org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) 在 org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293) 在 org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849) 在 org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583) 在 org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454) 在 java.lang.Thread.run(Thread.java:619) 引起原因:javax.xml.bind.UnmarshalException - 带有链接异常: [javax.xml.bind.UnmarshalException:意外元素(uri:”http://services.aristabi.com/ http://services.aristabi.com/", local:"searchCriteria")。预期元素为 ] 在 com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.handleStreamException(UnmarshallerImpl.java:425) 在com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:362) 在 com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:339) 在org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:749) ... 25 更多 引起原因:javax.xml.bind.UnmarshalException:意外元素(uri:“http://services.aristabi.com/ http://services.aristabi.com/", local:"searchCriteria")。预期元素为 在com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleEvent(UnmarshallingContext.java:642) 在 com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:254) 在 com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:249) 在 com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportUnexpectedChildElement(Loader.java:116) 在 com.sun.xml.bind.v2.runtime.unmarshaller.Loader.childElement(Loader.java:101) 在 com.sun.xml.bind.v2.runtime.unmarshaller.StructureLoader.childElement(StructureLoader.java:245) 在 com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext._startElement(UnmarshallingContext.java:478) 在 com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.startElement(UnmarshallingContext.java:459) 在 com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.handleStartElement(StAXStreamConnector.java:242) 在 com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.bridge(StAXStreamConnector.java:176) 在 com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:360) ... 27 更多 引起原因:javax.xml.bind.UnmarshalException:意外元素(uri:“http://services.aristabi.com/ http://services.aristabi.com/", local:"searchCriteria")。预期元素为 ... 38 更多

这可能是一个简单的问题,但我似乎无法解决它。谁能指出我解决这个问题的正确方向?

谢谢, 扎汉吉尔

顺便说一句,这就是我的 wsdl 的样子

<?xml version='1.0' encoding='UTF-8'?><wsdl:definitions name="ReportingServiceImplService" targetNamespace="http://services.aristabi.com/" xmlns:ns1="http://cxf.apache.org/bindings/xformat" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://services.aristabi.com/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<wsdl:types>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="unqualified"   targetNamespace="http://services.aristabi.com/" xmlns:tns="http://services.aristabi.com/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="getNewBusinessVolumeByCreateDate" type="tns:getNewBusinessVolumeByCreateDate" />
<xs:element name="getNewBusinessVolumeByCreateDateResponse" type="tns:getNewBusinessVolumeByCreateDateResponse" />
<xs:element name="getNewBusinessVolumeByCreateDate_v2" type="tns:getNewBusinessVolumeByCreateDate_v2" />
<xs:element name="getNewBusinessVolumeByCreateDate_v2Response" type="tns:getNewBusinessVolumeByCreateDate_v2Response" />
<xs:element name="newBusinessLead" type="tns:newBusinessLead" />
<xs:element name="quotes" type="tns:quotes" />
<xs:element name="searchCriteria" type="tns:searchCriteria" />
<xs:complexType name="getNewBusinessVolumeByCreateDate">
<xs:sequence>
  <xs:element minOccurs="0" name="agent" type="xs:string" />
  <xs:element minOccurs="0" name="broker" type="xs:string" />
  <xs:element minOccurs="0" name="businessUnit" type="xs:string" />
  <xs:element minOccurs="0" name="fromMonth" type="xs:string" />
  <xs:element minOccurs="0" name="fromYear" type="xs:string" />
  <xs:element minOccurs="0" name="region" type="xs:string" />
  <xs:element minOccurs="0" name="toMonth" type="xs:string" />
  <xs:element minOccurs="0" name="toYear" type="xs:string" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="getNewBusinessVolumeByCreateDateResponse">
<xs:sequence>
  <xs:element minOccurs="0" name="return" type="tns:newBusinessLead" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="newBusinessLead">
<xs:sequence>
  <xs:element maxOccurs="unbounded" minOccurs="0" name="convertedQuotes" nillable="true" type="tns:quotes" />
  <xs:element maxOccurs="unbounded" minOccurs="0" name="declinedQuotes" nillable="true" type="tns:quotes" />
  <xs:element maxOccurs="unbounded" minOccurs="0" name="ntuQuotes" nillable="true" type="tns:quotes" />
  <xs:element maxOccurs="unbounded" minOccurs="0" name="pendingQuotes" nillable="true" type="tns:quotes" />
  </xs:sequence>
</xs:complexType>
<xs:complexType name="quotes">
<xs:sequence>
  <xs:element minOccurs="0" name="month" type="xs:string" />
  <xs:element name="premium" type="xs:int" />
  <xs:element minOccurs="0" name="quoteStatus" type="xs:string" />
  <xs:element name="volume" type="xs:int" />
  <xs:element minOccurs="0" name="year" type="xs:string" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="arrayList">
<xs:complexContent>
  <xs:extension base="tns:abstractList">
    <xs:sequence />
  </xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType abstract="true" name="abstractList">
<xs:complexContent>
  <xs:extension base="tns:abstractCollection">
    <xs:sequence />
  </xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType abstract="true" name="abstractCollection">
<xs:sequence />
</xs:complexType>
<xs:complexType name="getNewBusinessVolumeByCreateDate_v2">
<xs:sequence>
  <xs:element minOccurs="0" name="searchCriteria" type="tns:searchCriteria" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="searchCriteria">
<xs:sequence>
  <xs:element minOccurs="0" name="agent" type="xs:string" />
  <xs:element minOccurs="0" name="broker" type="xs:string" />
  <xs:element minOccurs="0" name="businessUnit" type="xs:string" />
  <xs:element minOccurs="0" name="fromMonth" type="xs:string" />
  <xs:element minOccurs="0" name="fromYear" type="xs:string" />
  <xs:element minOccurs="0" name="region" type="xs:string" />
  <xs:element minOccurs="0" name="toMonth" type="xs:string" />
  <xs:element minOccurs="0" name="toYear" type="xs:string" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="getNewBusinessVolumeByCreateDate_v2Response">
<xs:sequence>
  <xs:element minOccurs="0" name="return" type="tns:newBusinessLead" />
</xs:sequence>
</xs:complexType>
<xs:element name="InvalidUserCredentialsException" type="tns:InvalidUserCredentialsException" />
<xs:complexType name="InvalidUserCredentialsException">
<xs:sequence />
</xs:complexType>
<xs:element name="tokenString" nillable="true" type="xs:string" />
</xs:schema>
</wsdl:types>
<wsdl:message name="InvalidUserCredentialsException">
<wsdl:part element="tns:InvalidUserCredentialsException" name="InvalidUserCredentialsException">
</wsdl:part>
</wsdl:message>
<wsdl:message name="getNewBusinessVolumeByCreateDateResponse">
<wsdl:part element="tns:getNewBusinessVolumeByCreateDateResponse" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:message name="getNewBusinessVolumeByCreateDate">
<wsdl:part element="tns:getNewBusinessVolumeByCreateDate" name="parameters">
</wsdl:part>
<wsdl:part element="tns:tokenString" name="tokenString">
</wsdl:part>
</wsdl:message>
<wsdl:message name="getNewBusinessVolumeByCreateDate_v2Response">
<wsdl:part element="tns:getNewBusinessVolumeByCreateDate_v2Response" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:message name="getNewBusinessVolumeByCreateDate_v2">
<wsdl:part element="tns:getNewBusinessVolumeByCreateDate_v2" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:portType name="IReportingService">
<wsdl:operation name="getNewBusinessVolumeByCreateDate">
  <wsdl:input message="tns:getNewBusinessVolumeByCreateDate" name="getNewBusinessVolumeByCreateDate">
</wsdl:input>
  <wsdl:output message="tns:getNewBusinessVolumeByCreateDateResponse" name="getNewBusinessVolumeByCreateDateResponse">
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="getNewBusinessVolumeByCreateDate_v2">
  <wsdl:input message="tns:getNewBusinessVolumeByCreateDate_v2" name="getNewBusinessVolumeByCreateDate_v2">
</wsdl:input>
  <wsdl:output message="tns:getNewBusinessVolumeByCreateDate_v2Response" name="getNewBusinessVolumeByCreateDate_v2Response">
</wsdl:output>
  <wsdl:fault message="tns:InvalidUserCredentialsException" name="InvalidUserCredentialsException">
</wsdl:fault>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="ReportingServiceImplServiceSoapBinding" type="tns:IReportingService">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="getNewBusinessVolumeByCreateDate">
  <soap:operation soapAction="" style="document" />
  <wsdl:input name="getNewBusinessVolumeByCreateDate">
    <soap:header message="tns:getNewBusinessVolumeByCreateDate" part="tokenString" use="literal">
    </soap:header>
    <soap:body parts="parameters" use="literal" />
  </wsdl:input>
  <wsdl:output name="getNewBusinessVolumeByCreateDateResponse">
    <soap:body use="literal" />
  </wsdl:output>
</wsdl:operation>
<wsdl:operation name="getNewBusinessVolumeByCreateDate_v2">
  <soap:operation soapAction="" style="document" />
  <wsdl:input name="getNewBusinessVolumeByCreateDate_v2">
    <soap:body use="literal" />
  </wsdl:input>
  <wsdl:output name="getNewBusinessVolumeByCreateDate_v2Response">
    <soap:body use="literal" />
  </wsdl:output>
  <wsdl:fault name="InvalidUserCredentialsException">
    <soap:fault name="InvalidUserCredentialsException" use="literal" />
  </wsdl:fault>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="ReportingServiceImplService">
<wsdl:port binding="tns:ReportingServiceImplServiceSoapBinding" name="ReportingServiceImplPort">
  <soap:address location="http://localhost:8889/AristaInsuranceServices/reportingService" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

我没有 XSD。您能指出 WSDL 有什么问题吗?


我知道这个问题已经存在一年了,没有公认的答案,但今天我遇到了完全相同的错误。

与原始问题发布者一样,我有一个 Java-First 服务,其中包含返回对象的方法。对我来说,问题是我向服务方法返回的 bean 添加了一个额外的属性。

一旦我重新发布/重新部署服务,客户端 jaxb 为返回对象生成的类不再与服务器端 WSDL 复杂类型相同(即客户端类缺少新属性),因此我有“意外元素” " 缺少属性名称的异常。

一旦我使用 WsdlToJava 重新生成了所有 jaxb 对象,客户端代码就可以正常工作。

我还遇到了针对这种情况的建议解决方法,您可能不希望每次服务器端的属性发生更改时都重新生成客户端代码。解决方案基本上是忽略客户端的意外元素异常,因为它是针对现有代码不使用的新元素。解决方案链接如下:
http://whileonefork.blogspot.com/2010/11/cxf-backwards-compatibility-adding.html http://whileonefork.blogspot.com/2010/11/cxf-backwards-compatibility-adding.html

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Apache CXF 2.2.7 Spring 3 Web 服务解组错误:意外元素 的相关文章

随机推荐

  • UI测试框架+持续集成?

    所以我有一个继承的应用程序 我想围绕它构建一个自动化测试套件 该应用程序在设计时并未考虑到可测试性 并且代码是一个 大泥球 我的计划是使用 UI 自动化测试框架 并在 UI 级别创建一套测试 直到我有足够的覆盖范围 让我能够充满信心地开始重
  • 类内声明的友元运算符中左手参数的隐式转换

    我正在使用 CRTP 向类提供依赖于模板参数的函数添加 在本例中添加operator and operator 使用模板类ImplAdd 对于前者 应该对两个参数执行隐式转换 这意味着我必须使用类内友元运算符 如下所示 template
  • 在多个程序中正确使用 Scikit 的 LabelEncoder

    我手头的基本任务是 a 读取一些制表符分隔的数据 b 进行一些基本的预处理 c 对于每个分类列使用LabelEncoder创建映射 这有点像这样 mapper Converting Categorical Data for x in cat
  • 需要使用hadoop原生

    我正在调用一个mapreduce我的java程序的工作 今天 当我设置mapreduce作业的输入格式为 LzoTextInputFormat The mapreduce作业失败 Could not load native gpl libr
  • python3.8 brotli brotli.error: BrotliDecompress failed?

    我的代码 python3 8 布罗特利 1 0 9 使用请求获取 url 标头使用 Accept Encoding br 我需要使用decode br 因为我认为使用accept encoding br更好 import brotli im
  • 如何让带有 HTML 标签的字符串在 React js 中渲染?

    我正在使用 Reactjs 和 Django 开发我的网站 我在 Django 管理中有 WYSIWYG 编辑器 所以当我发布带有文本装饰的帖子时 它会与 HTML 标签一起存储 在 React 中 我从 Django REST 框架获取
  • 获取日期和时间(以毫秒为单位)

    我想创建一个函数 用当前日期和时间填充结构 例如 typedef struct DateAndTime int year int month int day int hour int minutes int seconds int msec
  • 如何使用 COM OLE 对象进行 TDD

    我有一个 OLE COM 对象 试图为其编写包装器 我决定开始使用 TDD 为其编写代码 因为我相信这会让我对要编写的内容有更好的方向感 COM 对象有一个如下所示的接口 Interface Mapinfo Sub Do ByVal cmd
  • bassistance jQuery 表单验证插件 - 提交前电子邮件错误

    我正在使用这个插件 http bassistance de jquery plugins jquery plugin validation http bassistance de jquery plugins jquery plugin v
  • Python 3 CGI:如何输出原始字节

    我决定使用 Python 3 来制作我的网站 但我遇到了 Unicode 输出的问题 看似平淡print html html is astr应该可以工作 但事实并非如此 我明白了UnicodeEncodeError ascii codec
  • UIView动画改变按钮的大小

    我开始尝试从应用程序商店重新创建购买按钮 这需要两步点击才能购买东西 我设置按钮展开的动画 到目前为止我有这个 UIView beginAnimations nil context nil UIView setAnimationDurati
  • Flutter 中中间有文本的水平分隔线?

    Flutter 中是否有内置小部件来创建中间有文本的分隔线 有关于如何做的指南吗 像这样 水平线中间的 OR 文字 这是我想要实现的屏幕截图 https i stack imgur com VyJXx png 您可以尝试使用Row http
  • NSScanner 循环问题

    我有一个NSScanner扫描 HTML 文档中段落标签的对象 扫描仪似乎在找到的第一个结果处停止 但我需要数组中的所有结果 如何改进我的代码以浏览整个文档 NSArray getParagraphs NSString html NSSca
  • 如何在 YouCompleteMe 弹出菜单中使用 展开 UltiSnips 代码段?

    这个问题确实触动了我的神经 我两个都有你使我完整 https github com ycm core YouCompleteMe and 多功能剪 https github com sirver ultisnips安装在我的 vim 8 0
  • 为什么提交作业失败并显示“NoSuchMethodError: scala.runtime.VolatileObjectRef.zero()Lscala/runtime/VolatileObjectRef;”?

    我正在尝试提交 Spark 作业 它是这样开始的 import javax xml parsers SAXParser SAXParserFactory import org apache spark import org apache s
  • 如何在phpmyadmin中将分隔数据导入mysql

    这是使用中的数据示例 24701 37 279788 81 229023 WV BLUEFIELD MERCER 正如您所看到的 它是由双管道分隔的 phpmyadmin 要求我提供以下信息 Fields Terminated By Fie
  • C中如何使用函数uname

    我应该编写一个函数来获取有关系统的一些信息 最重要的信息是体系结构 我找到了这个功能uname可以使用的包括系统 utsname h 好吧 虽然我用谷歌搜索并阅读了文档 但我找不到该函数的任何示例 而且我不明白如何使用 uname 任何人都
  • 我如何在cmd行中运行maven项目

    我编写 Maven 项目并在 Eclipse 中运行它 但我想使用命令行运行 Maven 项目 所以我写 java jar Dapple awt UIElement true target myproject 1 0 SNAPSHOT ja
  • 使用curl --data测试REST路由,返回404

    我正在尝试 MEAN 堆栈教程 并且我位于 测试初始路由 https thinkster io mean stack tutorial opening rest routes testing the initial routes 步骤 我们
  • Apache CXF 2.2.7 Spring 3 Web 服务解组错误:意外元素

    我使用 Apache CXF 2 2 7 和 Spring 3 开发了一个简单的 Web 服务应用程序 并将其作为 WAR 文件部署到 Tomcat 上 但收到以下错误消息 2010 年 4 月 12 日 15 56 12 org apac