Author Message
Tuan
Joined: Nov 15, 2018
Messages: 9
Offline
Hello,
Please help with this problem:
How can I get the return values from a restful web service invocation? I follows the instruction to create a .rest file, configured it, add input and output parameters but no matter how I tried, the variables are empty. Apparently the return values were not assigned to the variables. Don't know where I missed. Anyone has a sample code of how to invoke restful web service in Avaya OD 7.0?

Thanks

Tuan P.
WilsonYu
Joined: Nov 6, 2013
Messages: 3950
Offline
Have you looked at the sample app called RESTConnectorExample? Do you know what the REST service is supposed to return? xml or json string? The trace.log can give you some information if you enable the localddtrace and localsoaptrace trace.
Tuan
Joined: Nov 15, 2018
Messages: 9
Offline
Hi Wilson,

Thank you very much for quick responding. After configuring the log, I found out that my app got exception "Connection reset". Can you please let me know what possible causes of this exception? I also attached the trace.log file for your review.


Thanks

Tuan P.
Filename trace.log [Disk] Download
WilsonYu
Joined: Nov 6, 2013
Messages: 3950
Offline
Network problem between your app server and the web service.

Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:189)
at java.net.SocketInputStream.read(SocketInputStream.java:121)
Tuan
Joined: Nov 15, 2018
Messages: 9
Offline
Hi Wilson,

Thank you very much for helping. I have managed to get it to work! However, I got a new issue: how can I get the response message from the web service using Axis2? Looking to other forums, it seems that I can NOT get it using Axis2; I have to use Apache common Http to get the response message from web service, is it right?


Thanks

Tuan
WilsonYu
Joined: Nov 6, 2013
Messages: 3950
Offline
Axis2 supports REST web service which returns either JSON or XML response. Have you tried the OD REST connector which is based on Axis2? The RESTConnector sample app can give you a head start.
Tuan
Joined: Nov 15, 2018
Messages: 9
Offline
Thank you Wilson. I have tried that. I meant if I get this response message, how can I store it into a java variable using Axis2?


30/01/2019 17:32:21:208 DEBUG - << "{"response":[{"message":"No data was found"}]}"

Thanks


Tuan
WilsonYu
Joined: Nov 6, 2013
Messages: 3950
Offline
The return value is automatically stored in the variable that is assigned to the return parameter you configure in the WSOP editor. It depends on what you've select as the output format in the Advance Option. By default, it's a string. If you selected JSON and Use Java Object, the return variable will have the JSONObject which you can further process in custom servlet code.
Tuan
Joined: Nov 15, 2018
Messages: 9
Offline
Hi Wilson,

Thank you very much for your help. I can get the return message stored in a variable assigned to return parameter. However, not all the return data are stored in this variable. The returned data should be an json Object with 3 level, but it looks like only 2 levels are returned and the 3rd level is missing. How can I make the data return in full?

I also attached the 2 returns: the expected and the actual ones for your review.


Thanks

Tuan
Filename expectedReturn.txt [Disk] Download
Filename actualReturn.txt [Disk] Download
WilsonYu
Joined: Nov 6, 2013
Messages: 3950
Offline
Can you enable localsoaptrace in data/ddrt.properties to show what the log shows in the return? It looks like you are missing the whole item "clients" at the first level in the JSON . I don't think there is any control in OD REST operation other than the REST service you are calling.
Tuan
Joined: Nov 15, 2018
Messages: 9
Offline
Hello Wilson,

I already configured the trace log and what the log showed is the same, that is, the whole "client" data is missing. However, when trying to use http library to call the same service in the same project, I got the full data return!
I also got full returned data when using SOAP UI on the same URL.
So is there anything setting in IVR system that I missed?

Thanks

Tuan
WilsonYu
Joined: Nov 6, 2013
Messages: 3950
Offline
Interesting...I don't know of such setting that would cut off that item. Is that anything in the log that indicates a problem? It is hard for me tell what the problem is without reproducing it.
WilsonYu
Joined: Nov 6, 2013
Messages: 3950
Offline
I did a test with a REST service I create mimicking the output of your expected JSON string and I found no problem in the OD REST operation. I also print out the JSON string in my custom OD code

public void servletImplementation(com.avaya.sce.runtimecommon.SCESession mySession) {

Object objJson = mySession.getVariableField(IProjectVariables.RSRET).getObjectValue();

JSONObject json = (JSONObject)objJson;
try {
JSONArray json2 = (JSONArray)json.get("policyBasic");
System.out.println(json2);
JSONObject json3 = (JSONObject)json2.get(0);
System.out.println(json3.get("clients"));
} catch (JSONException e) {
e.printStackTrace();
}



13/02/2019 11:19:59:932 INFO - 715F7F5A3778F86510997148164CCB33:/TestRest : Starting REST web service operation [rstest]
13/02/2019 11:20:00:011 DEBUG - 715F7F5A3778F86510997148164CCB33:/TestRest : Web Service Request -> http://localhost:8082/MyWebProject/MyServlet
13/02/2019 11:20:00:041 DEBUG - 715F7F5A3778F86510997148164CCB33:/TestRest : Storing [{"message":null,"policyBasic":[{"policyNo":"12291965 ","companyCode":"101","activeWorkflowSgnl":"Y","cssdTrackNo":null,"dataSrcCode":"CYBR","issueDate":"1990-10-08","policyStatusChngDate":"1990-10-08","policyStatusCode":"A ","clients":[{"passwdTxt":"PassJuly","birthDate":"1977-02-01","clientId":"","odsClientId":"1821757","nameType":"N","corpName":"","clientSeqNo":"01","clientSsnTaxId":"111116996","companyCode":"101","cssRegisteredSgnl":null,"emailAddrTxt":"monica.perez@test3.com ","firstName":"MONICA","invalidEmailSgnl":null,"lastName":"PEREZ","lastUpdtSrcName":"CLLOAD","lastUpdtTmstmp":"2019-02-08 19:53:09.280119","middleName":"","namePrfx":"","nameSufx":"","otherPhoneNo":"4096217713","paperlessOptionSgnl":null,"personalIdNo":0,"policyNo":"12291965 ","primaryPhoneNo":"4096920113","residentialStateCode":"TX","roleCode":"OW"}]}]}] to: rsret
13/02/2019 11:20:00:041 DEBUG - 715F7F5A3778F86510997148164CCB33:/TestRest : Web Service Reply <- {"message":null,"policyBasic":[{"policyNo":"12291965 ","companyCode":"101","activeWorkflowSgnl":"Y","cssdTrackNo":null,"dataSrcCode":"CYBR","issueDate":"1990-10-08","policyStatusChngDate":"1990-10-08","policyStatusCode":"A ","clients":[{"passwdTxt":"PassJuly","birthDate":"1977-02-01","clientId":"","odsClientId":"1821757","nameType":"N","corpName":"","clientSeqNo":"01","clientSsnTaxId":"111116996","companyCode":"101","cssRegisteredSgnl":null,"emailAddrTxt":"monica.perez@test3.com ","firstName":"MONICA","invalidEmailSgnl":null,"lastName":"PEREZ","lastUpdtSrcName":"CLLOAD","lastUpdtTmstmp":"2019-02-08 19:53:09.280119","middleName":"","namePrfx":"","nameSufx":"","otherPhoneNo":"4096217713","paperlessOptionSgnl":null,"personalIdNo":0,"policyNo":"12291965 ","primaryPhoneNo":"4096920113","residentialStateCode":"TX","roleCode":"OW"}]}]}
13/02/2019 11:20:00:043 INFO - 715F7F5A3778F86510997148164CCB33:/TestRest : Using SCESession 715F7F5A3778F86510997148164CCB33:/TestRest servlet : ParseJson
[{"policyNo":"12291965 ","companyCode":"101","activeWorkflowSgnl":"Y","cssdTrackNo":null,"dataSrcCode":"CYBR","issueDate":"1990-10-08","policyStatusChngDate":"1990-10-08","policyStatusCode":"A ","clients":[{"passwdTxt":"PassJuly","birthDate":"1977-02-01","clientId":"","odsClientId":"1821757","nameType":"N","corpName":"","clientSeqNo":"01","clientSsnTaxId":"111116996","companyCode":"101","cssRegisteredSgnl":null,"emailAddrTxt":"monica.perez@test3.com ","firstName":"MONICA","invalidEmailSgnl":null,"lastName":"PEREZ","lastUpdtSrcName":"CLLOAD","lastUpdtTmstmp":"2019-02-08 19:53:09.280119","middleName":"","namePrfx":"","nameSufx":"","otherPhoneNo":"4096217713","paperlessOptionSgnl":null,"personalIdNo":0,"policyNo":"12291965 ","primaryPhoneNo":"4096920113","residentialStateCode":"TX","roleCode":"OW"}]}]
[{"passwdTxt":"PassJuly","birthDate":"1977-02-01","clientId":"","odsClientId":"1821757","nameType":"N","corpName":"","clientSeqNo":"01","clientSsnTaxId":"111116996","companyCode":"101","cssRegisteredSgnl":null,"emailAddrTxt":"monica.perez@test3.com ","firstName":"MONICA","invalidEmailSgnl":null,"lastName":"PEREZ","lastUpdtSrcName":"CLLOAD","lastUpdtTmstmp":"2019-02-08 19:53:09.280119","middleName":"","namePrfx":"","nameSufx":"","otherPhoneNo":"4096217713","paperlessOptionSgnl":null,"personalIdNo":0,"policyNo":"12291965 ","primaryPhoneNo":"4096920113","residentialStateCode":"TX","roleCode":"OW"}]
JoseGil
Joined: Apr 16, 2017
Messages: 2
Offline
Tuan

Did you solve the problem? I am having the same issue when I used web services: The response it is not received into the variable, but if if I used SoapUI I could get the answer, also if I did a Wireshark trace I saw the answer data.
Go to:   
Mobile view