Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/360.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java UnmarshaleException:在springboot中捕获对象中的xml rest web服务响应时出现意外元素_Java_Xml_Spring Boot_Rest_Unmarshalling - Fatal编程技术网

Java UnmarshaleException:在springboot中捕获对象中的xml rest web服务响应时出现意外元素

Java UnmarshaleException:在springboot中捕获对象中的xml rest web服务响应时出现意外元素,java,xml,spring-boot,rest,unmarshalling,Java,Xml,Spring Boot,Rest,Unmarshalling,问题: 原因:javax.xml.bind.UnmarshaleException:意外元素(uri:)http://www.original.com/webapp-response“,本地:“响应”)。预期的要素是 通过SOAP UI的Rest web服务xml响应: <response status="ok" xsi:schemaLocation="http://www.original.com/webapp-response http://schemas

问题: 原因:javax.xml.bind.UnmarshaleException:意外元素(uri:)http://www.original.com/webapp-response“,本地:“响应”)。预期的要素是

通过SOAP UI的Rest web服务xml响应:

<response status="ok" xsi:schemaLocation="http://www.original.com/webapp-response http://schemas.original.com/releases/11.3/webapp-response.xsd" xmlns="http://www.original.com/webapp-response" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <eventResponse>
      <transactionList>
         <transaction>
            <id>1234567</id>
         </transaction>
         <transaction>
            <id>1324567</id>
         </transaction>
         <transaction>
            <id>1432567</id>
         </transaction>
         <transaction>
            <id>1523467</id>
         </transaction>
      </transactionList>
   </eventResponse>
</response>

1234567
1324567
1432567
1523467
创建的响应域是:

@SuppressWarnings("PMD")
@XmlRootElement(name="transactionList")
@XmlAccessorType(XmlAccessType.FIELD)
public class TransactionResponse {

    @XmlElement(name="transactionList")
    private List<Transaction> transactionList;

    public List<Transaction> getTransactionList() {
        return transactionList;
    }
    public void setTransactionList(List<Transaction> transactionList) {
        this.transactionList = transactionList;
    }
}

@XmlAccessorType(XmlAccessType.FIELD)
public class Transaction {
    
    @XmlAttribute(name = "id")
    private String id;
    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
}
@SuppressWarnings(“PMD”)
@XmlRootElement(name=“transactionList”)
@XmlAccessorType(XmlAccessType.FIELD)
公共类事务响应{
@XmlElement(name=“transactionList”)
私人清单交易清单;
公共列表getTransactionList(){
返回事务列表;
}
public void setTransactionList(列表transactionList){
this.transactionList=transactionList;
}
}
@XmlAccessorType(XmlAccessType.FIELD)
公共类事务{
@xmltattribute(name=“id”)
私有字符串id;
公共字符串getId(){
返回id;
}
公共无效集合id(字符串id){
this.id=id;
}
}
通过rest模板交换方法捕获对象响应的Java代码:

    HttpHeaders requestHeaders = new HttpHeaders();
    Map<String, String> params = new HashMap<String, String>();
    
    params.put("action", "Transactions");
    params.put("startDate", "14092020 00:00:00");
    params.put("endDate", "14092020 23:59:59");
            
    requestHeaders.add("Accept", MediaType.APPLICATION_JSON_VALUE);
    requestHeaders.add("Cookie", strSession);
    HttpEntity<Object> entity = new HttpEntity<>(requestHeaders);
                    
    ResponseEntity<TransactionResponse> response = null;
    restTemplate = new RestTemplate();
    response = restTemplate.exchange(eoLoginURL, HttpMethod.POST, entity, TransactionResponse.class, params);
HttpHeaders requestHeaders=新的HttpHeaders();
Map params=新的HashMap();
参数出售(“行动”、“交易”);
参数put(“起始日期”,“14092020 00:00:00”);
参数put(“结束日期”,“14092020 23:59:59”);
requestHeaders.add(“Accept”,MediaType.APPLICATION\u JSON\u VALUE);
添加(“Cookie”,stression);
HttpEntity=新的HttpEntity(RequestHeader);
ResponseEntity response=null;
restTemplate=新的restTemplate();
response=restemplate.exchange(eoLoginURL,HttpMethod.POST,entity,TransactionResponse.class,params);
有人能指出什么是根本原因或遗漏了什么吗