- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
我正在使用以下代码解析soap响应,但我收到UnmarshallingFailureException,我将@XmlSeeAlso更改为@XMLRootElement,但问题仍然存在。 WSDL 是 here .
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>
代码
@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)
public class Request {
@XmlElement(name = "Departure")
private String departure;
@XmlElement(name = "Destination")
private String destination;
@XmlElement(name = "DepartureDate")
private String departureDate;
@XmlElement(name = "ReturnDate")
private String returnDate;
@XmlElement(name = "NumADT")
private int numADT;
@XmlElement(name = "NumINF")
private int numInf;
@XmlElement(name = "NumCHD")
private int numCHD;
@XmlElement(name = "CurrencyCode")
private String currencyCode;
@XmlElement(name = "WaitForResult")
private boolean waitForResult;
@XmlElement(name = "NearByDepartures")
private boolean nearByDepartures;
@XmlElement(name = "NearByDestinations")
private boolean nearByDestinations;
@XmlElement(name = "RROnly")
private boolean rronly;
@XmlElement(name = "MetaSearch")
private boolean metaSearch;
getters and setters
@XmlRootElement(name="Response")
@XmlAccessorType(XmlAccessType.FIELD)
public class Response {
@XmlElement(name="SearchFlightId")
private String searchFlightId;
@XmlElement(name="Roundtrip")
private boolean roundTrip;
@XmlElement(name="CurrencyCode")
private String currencyCode;
@XmlElement(name="Flights")
private Flights flights;
getters and setters
@XmlSeeAlso(Flight.class)
@XmlAccessorType(XmlAccessType.FIELD)
public class Flights {
@XmlElement(name="Flight")
private List<Flight> flight;
getter and setter
@XmlSeeAlso(Outbound.class)
@XmlAccessorType(XmlAccessType.FIELD)
public class Flight {
@XmlElement(name = "Outbound")
private Outbound outbound;
@XmlElement(name="Inbound")
private Inbound inbound;
@XmlElement(name = "BagFee")
private int bagFee;
@XmlElement(name = "CcFee")
private int ccFee;
@XmlElement(name = "HandlingFee")
private int handlingFee;
@XmlElement(name = "TotalFare")
private int totalFare;
@XmlElement(name = "FlightId")
private String flightId;
@XmlElement(name = "Link2Book")
private String link2Book;
@XmlElement(name = "Provider")
private String provider;
getters and setters
@XmlRootElement(name = "Outbound")
@XmlAccessorType(XmlAccessType.FIELD)
public class Outbound {
@XmlElement(name="CarName")
private String carName;
@XmlElement(name="CarCode")
private String carCode;
@XmlElement(name="DepName")
private String depName;
@XmlElement(name="DepCode")
private String depCode;
@XmlElement(name="DestName")
private String destName;
@XmlElement(name="DestCode")
private String destCode;
@XmlElement(name="Duration")
private String duration;
@XmlElement(name="FlightNo")
private String flightNo;
@XmlElement(name="DepDateTime")
private Date dapDateTime;
@XmlElement(name="ArrDateTime")
private Date arrDateTime;
@XmlElement(name="Legs")
private Legs legs;
@XmlElement(name="Taxes")
private int taxes;
@XmlElement(name="FareADT")
private int fareADT;
@XmlElement(name="FareCHD")
private int fareCHD;
@XmlElement(name="FareINF")
private int fareInf;
@XmlElement(name="MiscFees")
private int miscFees;
@XmlElement(name="Idx")
private int idx;
@XmlElement(name="FareClass")
private String fareClass;
@XmlElement(name="FareType")
private String fareType;
@XmlElement(name="FareId")
private String fareId;
getters and setters
@XmlRootElement(name="Legs")
@XmlAccessorType(XmlAccessType.FIELD)
public class Legs {
@XmlElement(name="Leg")
private Leg leg;
getter and setter
@XmlRootElement(name="Leg")
@XmlAccessorType(XmlAccessType.FIELD)
public class Leg {
@XmlElement(name="Sequence")
private int sequence;
@XmlElement(name="FlightNo")
private String flightNo;
@XmlElement(name="DepCode")
private String depCode;
@XmlElement(name="DepName")
private String depName;
@XmlElement(name="DestCode")
private String destCode;
@XmlElement(name="DestName")
private String destName;
@XmlElement(name="DepTime")
private String depTime;
@XmlElement(name="ArrTime")
private String arrTime;
@XmlElement(name="CarCode")
private String carCode;
@XmlElement(name="CarName")
private String carName;
@XmlElement(name="FareClass")
private String fareClass;
@XmlElement(name="ArrDateTime")
private Date arrDateTime;
@XmlElement(name="DepDateTime")
private Date depDateTime;
getters and setters
@XmlRootElement(name = "Inbound")
@XmlAccessorType(XmlAccessType.FIELD)
public class Inbound {
@XmlElement(name="CarName")
private String carName;
@XmlElement(name="CarCode")
private String carCode;
@XmlElement(name="DepName")
private String depName;
@XmlElement(name="DepCode")
private String depCode;
@XmlElement(name="DestName")
private String destName;
@XmlElement(name="DestCode")
private String destCode;
@XmlElement(name="Duration")
private String duration;
@XmlElement(name="FlightNo")
private String flightNo;
@XmlElement(name="DepDateTime")
private Date dapDateTime;
@XmlElement(name="ArrDateTime")
private Date arrDateTime;
@XmlElement(name="Legs")
private Legs legs;
@XmlElement(name="Taxes")
private int taxes;
@XmlElement(name="FareADT")
private int fareADT;
@XmlElement(name="FareCHD")
private int fareCHD;
@XmlElement(name="FareINF")
private int fareInf;
@XmlElement(name="MiscFees")
private int miscFees;
@XmlElement(name="Idx")
private int idx;
@XmlElement(name="FareClass")
private String fareClass;
@XmlElement(name="FareType")
private String fareType;
@XmlElement(name="FareId")
private String fareId;
gettes and setters
jaxb.index
SearchFlights
Flight
Flights
Leg
Legs
Outbound
Request
Response
WegoloSoapMessage
package-info.java
@XmlSchema(
namespace = "ElsyArres.API",
elementFormDefault = XmlNsForm.QUALIFIED)
package com.myproject.flights.wegolo;
import javax.xml.bind.annotation.XmlNsForm;
import javax.xml.bind.annotation.XmlSchema;
回应
1
2
3
4
5
6
最佳答案
错误消息指出,您正在尝试解析本地节点 searchflightsresponse
,您没有将其映射到类中作为注释。
您必须像之前对另一个节点所做的那样声明此节点。
请注意,这里不建议使用 jaxb 来解析 soap 响应,因为结构(如您所见)并非微不足道。我建议下载 wsdl 并生成客户端 stub 以匹配 web 服务。这样您就不需要注释数百个成员和类。
关于java - 无法使用 JAXB org.springframework.oxm.UnmarshallingFailureException 解析 XML 消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34825333/
刚开始处理Maven和Spring。当我尝试创建DAO和ResultSet然后运行应用程序时,抛出errors: Error:(4, 31) java: package org.springframe
问题: Error:(15, 10) java: cannot find symbol symbol: class SpringRunner Error:(16, 2) java: cannot
我正在尝试构建这个 RESTful 服务示例:https://spring.io/guides/gs/rest-service/GreetingController.java 的导入没有错误: pac
如果我尝试向构造函数注入(inject) Facebook 参数,我将尝试使用 facebook api 使用 spring + thymeleaf + hibernate 创建 Facebook 应
如何解决Spring中Bean的自动连接歧义?我们有一个 Dessert 接口(interface),并且有实现该接口(interface)(Dessert)的三种不同的甜点(Bean)。 今天的甜点
请问为什么我的 pom.xml 文件中会出现此错误 Missing artifact org.springframework:spring-context:jar:${org.springframew
让 gradle 构建正常工作( from a previous question related to this one ),安迪·威尔金森(Andy Wilkinson)为我回答,没有问题。正在为
我正在 tomcat 7 中开发网站(spring 3.1.1),但出现错误 ERROR: org.springframework.web.context.ContextLoader - Contex
我在将航类信息保存到 mysql 数据库时遇到错误。请帮助我下面是我的代码: 我已经尝试了所有方法,添加模式和这么多 它不会从字符串转换为日期 控制台日志 2020-05-12 13:19:21.04
我使用intellij创建了一个小型java应用程序,后来我使用“添加框架支持”选项将该项目更新为Maven项目。当我厌倦了在项目上添加 spring jar 文件时,出现以下错误:“没有为 org.
我尝试使用 org.springframework.data.mongodb.core.MongoOperations 从 mongo 集合中查询记录。我在 CompanyTemplRepoImpl
我尝试将 Spring4 与 Hibernate5 一起使用,但出现此错误: org.springframework.orm.jpa.EntityManagerHolder cannot be cas
我是这个论坛的新手。我正在尝试使用 spring 3.2.6 和 tomcat 7.0 制作一个应用程序。我已将所有必需的 jar 添加到 WEB-INF/lib 文件夹中。 DispatcherSe
我在 maven 架构中使用 Spring 框架 4.0.1.RELEASE、OAuth Security 2.0.7.RELEASE,当我编译代码时,出现以下错误。 SEVERE: Exceptio
我正在使用以下指令开发 CRUD Web 应用程序: https://www.javaguides.net/2019/02/spring-boot-2-angular-7-crud-example-t
这个问题已经有答案了: what is the difference in org.springframework.web.servlet.ModelAndView vs org.springfram
我正在尝试将 hibernate 与 spring boot 一起使用。但我收到此错误:org.springframework.orm.jpa.EntityManagerHolder 无法转换为 or
我尝试创建简单的用户登录和注册页面。但我无法使用服务方法创建用户。我有创建新用户的服务。 @Service public class LocalUserDetailsService implement
我用 STS、Roo 和 GWT 创建了一个新项目,并尝试包含 Spring Security。 从那时起,我收到以下错误。有没有人知道出了什么问题?! org.springframework.bea
这些是我正在使用的版本和依赖项 我怀疑版本需要更改但更改为什么,我不确定 springCore : '5.3.3', springjdbc
我是一名优秀的程序员,十分优秀!