AnsweredAssumed Answered

How to set arguments using scriptable DPH?

Question asked by venukg on May 9, 2018
Latest reply on May 9, 2018 by Rick.Brown

I want to set arguments in VSI using scriptable DPH for xml message which is having CDATA with JSON message.

I have approached below process, but still service is not working.

 

1.Downloaded json-simple-1.1.jar file and placed into lib>core folder.

2. Reloaded the devtest workstation

3. while creating virtual service I have selected Scriptable DPH.

4. added script as below.

import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
import com.itko.util.ParameterList;
import com.itko.util.Parameter;
 
JSONParser parser = new JSONParser();
 
String str1 = testExec.getStateValue("Test_Process");

String str = str1.substring(str1.indexOf("CDATA[")+6,str1.lastIndexOf("}")+1);
str = str.trim();
 
JSONObject jsonObject = (JSONObject) parser.parse(str);
String ProductCode = (String) jsonObject.get("hoganProductCode");

lisa_vse_request.setOperation("process");
ParameterList args = lisa_vse_request.getArguments();
args.addParameter(new Parameter("Hogan_Productcode", ProductCode));
lisa_vse_request.setArguments(args);

 

5. created virtual service.

6. added XML Xpath query filter on Listener step and added property as "Test_Process".

7.  loaded VSI and added argument as "Hogan_Productcode".

8. saved the changes and deployed the service into VSE.

 

below is request message which I have used for this service.

 

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ms="http://service.xyz.com/entity/msg/2017/" xmlns:hg="http://service.xyz.com/pdr/HG/entity/envelope/2017/">
  <SOAP-ENV:Header>
    <ms:Context>
      <ms:messageId>1</ms:messageId>
    </ms:Context>
    <hg:arContext>
      <service>DT</service>
      <action>getInformation</action>
    </hg:arContext>
  </SOAP-ENV:Header>
  <SOAP-ENV:Body>
    <ns:process xmlns:ns="http://service.xyz.com/provider/HG/data/DT/2017/">

&lt;![CDATA[{
  "TransactionsRequest": {
   "startDate":"2017-08-07T00:00:00-00:00",
   "endDate":"2017-08-08T00:00:00-00:00",
   "Key":{
     "Number":123456,
  "ProductCode":"ABCDE",
  
   }
  }
}]]&gt;

</ns:process>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

 

can some one review my code and help me to resolve the issue.

Outcomes