This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Need to handle size of array dynamically in SOAP response structure and update the values of array item

Considering a XML tag <get:numberOfDays xmlns:get="abc.com">30</get:numberOfDays>, we will need to provide the date slots available in response structure. 

For example, response structure - 

<availableDatesList xmlns="http://abc.com">
<availableDate>
<ent:installStartDateTime>30122023 12:00</ent:installStartDateTime>
<ent:installEndDateTime>30122023 16:00</ent:installEndDateTime>
</availableDate>
<availableDate>
<ent:installStartDateTime>30122023 08:00</ent:installStartDateTime>
<ent:installEndDateTime>30122023 12:00</ent:installEndDateTime>
</availableDate>
<availableDate>
<ent:installStartDateTime>29122023 12:00</ent:installStartDateTime>
<ent:installEndDateTime>29122023 16:00</ent:installEndDateTime>
</availableDate>
</availableDatesList>

 

  • 0

    You can use Scripted rule and read response xml or as a string. below is the sample script to update it as a string.

    int numberOfDays = sv.Request.numberOfDays;
    string installStartDateTime = "30122023 12:00";
    string installEndDateTime = "30122023 16:00";
    string availableDateObject = "<ent:installStartDateTime>" + installStartDateTime + "</ent:installStartDateTime><ent:installEndDateTime>" + installEndDateTime + "</ent:installEndDateTime>";
    string output = "";

    for(int i =0;i<numberOfDays;i++){
    output += availableDateObject;
    }
    sv.Response.availableDatesList = output;

  • 0 in reply to 

    Hi Syed, 

    Thank you for your response. We have tried to implement the same and received below error.

    Error - 'AvailablSeDate', rule 'Scripted Rule 1', operation 'request': Error [42:70] Cannot implicitly convert type 'string' to 'HP.SV.CSharp.AvailableDatesListType' (CS0029).

    Could you please help us on it.

  • 0 in reply to 

    Share your script rule and the full sample response object. I will check it.

  • 0 in reply to 

    Hi Syed, Could you please share any FTP to share the details required.