Spring Web返回无效响应

时间:2019-05-28 09:42:51

标签: java spring rest spring-web

我正在使用spring-web-4.3.10.RELEASE库。

我从这个库中调用RestTemplate的postForEntity()方法(实体由getRestOperations()返回),

getRestOperations().postForEntity(getEndpoint(), new HttpEntity<String>(requestStr, headers), String.class);

但是返回的响应不正确(已通过SOAP UI等某些工具测试)

Json的数组[]预期为

{
  "Header": {
    "Security": {
      "Timestamp": {
        "Created": "2019-05-27T13:16:57Z",
        "Expires": "2019-05-27T13:18:27Z"
      }
    }
  },
  "Body": {
    "NResponse": {
      "NoteInqRec": [
        {
          "NoteInfo": {
            "BranchDetails": ""
          }
        },
        {
          "NoteInfo": {
            "BranchDetails": ""
          }
        }
      ]
    }
  }
}

使用spring-web lib的代码响应我得到了(返回的json甚至无效):

{
  "Header": {
    "Security": {
      "Timestamp": {
        "Created": "2019-05-27T13:16:57Z",
        "Expires": "2019-05-27T13:18:27Z"
      }
    }
  },
  "Body": {
    "NResponse": {
      "NoteInqRec": 
        {
          "NoteInfo": {
            "BranchDetails": ""
          }
        },
        "NoteInqRec":
        {
          "NoteInfo": {
            "BranchDetails": ""
          }
        }
    }
  }
}

请帮助

0 个答案:

没有答案