Genesys CTI User Forum
Genesys CTI User Forum => Genesys CTI Technical Discussion => Topic started by: bilge on August 01, 2018, 08:40:05 AM
-
We need to parse the xml response of a SOAP web service and the output xml has a list. We can get the result AppState.Variable.SearchServResponse.SearchServResult["a:BBB"] if there is not a list. But in our example, xml is like the following one I posted and we cannot get the Num[0] for the first response, for instance. Does anybody know how the syntax should be for our case? Composer version is the latest one. We tried to get the response using array but could not be successful.
Thank you in advance,
BR
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<SearchServResponse xmlns="http://tempuri.org/">
<SearchServResult xmlns:a="http://schemas.org" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<a:SearchList>
<a:SearchRow>
<a:SearchInfo>
<a:CodeNum>111</a:AreaCodeNum>
<a:Date>2010-04-10T00:00:00</a:ClaimDate>
<a:Num>1111</a:ClaimNum>
</a:SearchInfo>
<a:SearchInfo>
<a:CodeNum i:nil="true"/>
<a:Date>2010-04-10T00:00:00</a:ClaimDate>
<a:Num>2222</a:ClaimNum>
</a:SearchInfo>
</a:SearchRow>
</a:SearchList>
<a:OutHeader xmlns:b="http://schemas.org">
<b:IsSuccessfull>true</b:IsSuccessfull>
<b:ResponseMessage>Success</b:ResponseMessage>
<b:Responsecode>1</b:Responsecode>
</a:OutHeader>
</SearchServResult>
</SearchServResponse>
</s:Body>
</s:Envelope>
-
Check your MCP logs, enable debug at that block and check the JSON returned by it.
Enviado de meu E6633 usando o Tapatalk
-
Hi cavagnaro,
MCP logs and GVP Debugger results are limited, it can only show us a specific number of characters for JSON. The only thing special is the "[" character after SearchInfo, which means an array is defined at this point.
Expression [var WSResponse = {"SearchServResponse":{"@xmlns":"http://tempuri.org/","SearchServResult":{"@xmlns:a":"http://schemas.org" xmlns:i="http://www.w3.org/2001/XMLSchema-instance","a:SearchList":{"a:SearchRow":{"a:SearchInfo":[{"a:CodeNum":{"@i:nil":"true"},"a:Date":"2010-10-26T00:00:00","a:Num":"1111"
Thank you,
-
Ermmm just do a JSON.stringify at the next block of your variable in the log section with debug level.
Or add a log block after your WS request
Enviado de meu E6633 usando o Tapatalk
-
Hi,
I tried JSON.stringify with debug level but the response is still limited.
-
Wireshark then or a soap UI, or at Tomcat logs look for composer logs
Enviado de meu E6633 usando o Tapatalk
-
Sorry for the late response. I converted the xml response to json format.
{
"s:Envelope": {
"-xmlns:s": "http://schemas.xmlsoap.org/soap/envelope/",
"s:Body": {
"SearchResponse": {
"-xmlns": "http://tempuri.org/",
"SearchResult": {
"-xmlns:a": "http://schemas.org/",
"-xmlns:i": "http://www.w3.org/2001/XMLSchema-instance",
"a:SearchList": {
"a:SearchRow": {
"a:SearchInfo": [
{
"a:CodeNum": { "-i:nil": "true" },
"a:Date": "2010-04-10T00:00:00",
"a:Num": "1111",
"a:List": {
"a:Row": {
"a:Info": [
{
"a:Name": "AAA"
},
{
"a:Name": "BBB"
}
]
}
},
"a:PhoneNum": { "-i:nil": "true" }
},
{
"a:CodeNum": { "-i:nil": "true" },
"a:Date": "2010-04-01T00:00:00",
"a:Num": "2222",
"a:List": {
"a:Row": {
"a:Info": [
{
"a:Name": "CCC"
},
{
"a:Name": "DDD"
},
{
"a:Name": "EEE"
}
]
}
},
"a:PhoneNum": { "-i:nil": "true" }
}
]
}
},
"a:OutHeader": {
"-xmlns:b": "http://schemas.org",
"b:IsSuccessfull": "true",
"b:ResponseMessage": "Success",
"b:Responsecode": "1"
}
}
}
}
}
}
-
Wait but this is how MCP converts it? Or you did a manually conversion?
For being a MCP one looks weird
Enviado de meu E6633 usando o Tapatalk
-
MCP did not show the entire JSON in its logs, so I used an online converter. It seems consistent with partial MCP log I posted before.
-
Yeah...which is weird because seems the xml is not converted correctly. The JSON should contain only the XML elements, not the whole headers and definitions.
Which block are you using?
Enviado de meu E6633 usando o Tapatalk
-
I need the first Name of the Info block "AAA" for instance.
-
Expression below should return 'AAA' assuming that JSON object (shown in your previous post) is stored in the AppState.Variable.SearchServResponse variable
AppState.Variable.SearchServResponse['s:Envelope']['s:Body']['SearchResponse']['SearchResult']['a:SearchList']['a:SearchRow']['a:SearchInfo'][0]['a:List']['a:Row']['a:Info'][0]['a:Name']
R.
-
Thank you guys, I can get the parameter now. I need to be more patient next time, it was all about json. I thought it is not possible to get the parameter after some trials similar to the right method, so I posted it here.
Best Regards.
-
Still looks weird for me...the JSON should be more friendly, without all that info about the WS itself.