Oracle MCS CustomAPI response is a JSON String .I want to store the JSON string in separate String parameter to create datacontrol.
{
"Header": {
"MessageID": "uE60F40847D",
"ReplyTo": {
"Address": "http:2005/08/addressing/anonymous"
},
"FaultTo": {
"Address": "http://www.w3.org2005"
}
},
"Body": {
"processResponse": {
"PERSON_ID": "45",
"GROUPS_ID": "54",
"PERSON_LOGIN": "s",
"PERSON_ROLE": "s",
"PERSON_UID": "4655",
"PERSON_NAME": "Welcome! Sanka",
"ERROR_CODE": "y",
"ERROR_MSG": "Login Successful"
}
}
}
Can anyone help me?
Create a class called Response
with parameters
private int responseCode;
private String responseMessage;
also generate getters and setters for the parameters.
then from your ServiceImplementation
class create an object of the class Response
and set the response string to <object>.setResponseMessage(<String containing your response>)
;
In your bean or Pojo class
JSONObject jsonObject= new JSONObject(response.getResponseMessage());
JSONObject headerObject = jsonObject.getJsonObject("Header");
then you will get all the "Header" parameters in the headerObject
and you can have individual value by headerObject.getString("<KeyName>")
.
Like above you can also parse "Body". Assign these values to an ArrayList
and create datacontrol.
If you have any doubts in the steps , feel free to ask