例如:我从GET服务返回了如下响应。我想评估URL:URL2.com和URL7.com中的一个或多个,并存储结果。做这件事的好方法是什么。我知道使用UTL_HTTP进行GET调用的方法,但在这种情况下,我应该对'parent' URL进行GET调用,然后对所有必需的子请求进行进一步的GET调用吗?
{
"items": [
{
"PersonId": 1,
"PersonNumber": "2",
"CorrespondenceLanguage": null,
"BloodType": null,
"DateOfBirth": "1970-03-11",
"DateOfDeath": null,
"CountryOfBirth": null,
"RegionOfBirth": null,
"TownOfBirth": null,
"ApplicantNumber": null,
"CreatedBy": "",
"CreationDate": "2018-06-21T03:46:31.499+00:00",
"LastUpdatedBy": "",
"LastUpdateDate": "2021-05-25T10:52:05.751+00:00",
"links": [
{
"rel": "self",
"href": "URL1.com",
"name": "workers",
"kind": "item",
"properties": {
"changeIndicator": "X"
}
},
{
"rel": "canonical",
"href": "URL2.com",
"name": "workers",
"kind": "item"
},
{
"rel": "child",
"href": "URL3.com",
"name": "addresses",
"kind": "collection"
}
]
},
{
"PersonId": 2,
"PersonNumber": "1",
"CorrespondenceLanguage": null,
"BloodType": null,
"DateOfBirth": "1969-07-04",
"DateOfDeath": null,
"CountryOfBirth": null,
"RegionOfBirth": null,
"TownOfBirth": null,
"ApplicantNumber": null,
"CreatedBy": "X.X",
"CreationDate": "2020-03-06T14:05:09+00:00",
"LastUpdatedBy": "",
"LastUpdateDate": "2021-04-26T23:01:31.867+00:00",
"links": [
{
"rel": "self",
"href": "URL5.com",
"name": "workers",
"kind": "item",
"properties": {
"changeIndicator": "X"
}
},
{
"rel": "canonical",
"href": "URL6.com",
"name": "workers",
"kind": "item"
},
{
"rel": "child",
"href": "URL7.com",
"name": "addresses",
"kind": "collection"
}
]
}
],
"count": 25,
"hasMore": true,
"limit": 25,
"offset": 0,
"links": [
{
"rel": "self",
"href": "URL8",
"name": "workers",
"kind": "collection"
}
]
}
1条答案
按热度按时间zmeyuzjn1#
要使用Oracle PL/SQL评估以HATEOAS格式返回的URL,可以执行以下步骤:
1.解析JSON响应。
1.遍历URL
1.发出GET请求
1.处理响应
下面是一个示例PL/SQL脚本,可以帮助您入门:
此脚本将帮助您解析JSON响应并从“links”数组中提取URL,并向您感兴趣的URL发出GET请求。您需要根据您的特定需求添加错误处理和进一步处理。