0

I am trying to get the response of all ax21:responseBean from soap, how ever with my code I am only getting the last inserted response bean.

My code is below.

 XmlNodeList xnList = document.SelectNodes("//ns:return", manager);
 int nodes = xnList.Count;

 foreach (XmlNode xn in xnList)
            {
                if (xn["ax21:resultText"].InnerText == "Successful")
                {
                    XmlNodeList xnList1 = document.SelectNodes("//ax21:responseBean", manager);
                    int nodes1 = xnList1.Count;

                    foreach (XmlNode xn1 in xnList1)
                    {
                        if (xn1["ax21:creditTokenName"].InnerText == "FreeMoney")
                        {
                            ct.Status = "True";
                            ct.creditTokenName = xn1["ax21:creditTokenName"].InnerText;
                            ct.uniqueTokenID = xn1["ax21:uniqueTokenID"].InnerText;
                        }
                        else
                        {
                            ct.Status = "False";
                            ct.creditTokenName = "Null";
                            ct.uniqueTokenID = "Null";
                        }

                    }
                } else
                {
                    ct.Status = "False";
                }
            }

SOAP UI Return values.

<ns:return xsi:type="ax21:GetCreditTokensResponse" xmlns:ax21="http://beans.webservice.CSI.omvia.convergys.com/xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <ax21:responseBean xsi:type="ax21:GetCreditTokenResponseBean">
           <ax21:allocationTime>2017-07-14T10:30:00.000+00:00</ax21:allocationTime>
           <ax21:creditTokenName>FreeMoney</ax21:creditTokenName>
           <ax21:creditTokenType>M</ax21:creditTokenType>
           <ax21:cumulativeFlag>false</ax21:cumulativeFlag>
           <ax21:endTime>2017-07-15T10:30:00.000+00:00</ax21:endTime>
           <ax21:originalValue>2.5</ax21:originalValue>
           <ax21:promotionName>Default Campaign</ax21:promotionName>
           <ax21:recurCost>0.0</ax21:recurCost>
           <ax21:recurDate xsi:nil="true"/>
           <ax21:recurFlag>false</ax21:recurFlag>
           <ax21:recurInterval></ax21:recurInterval>
           <ax21:recurValue>0.0</ax21:recurValue>
           <ax21:startTime>2017-07-14T10:29:00.000+00:00</ax21:startTime>
           <ax21:uniqueTokenID>4574332</ax21:uniqueTokenID>
           <ax21:value>2.5</ax21:value>
        </ax21:responseBean>
        <ax21:responseBean xsi:type="ax21:GetCreditTokenResponseBean">
           <ax21:allocationTime>2017-07-14T11:01:00.000+00:00</ax21:allocationTime>
           <ax21:creditTokenName>FreeMoney</ax21:creditTokenName>
           <ax21:creditTokenType>M</ax21:creditTokenType>
           <ax21:cumulativeFlag>false</ax21:cumulativeFlag>
           <ax21:endTime>2017-07-18T09:20:00.000+00:00</ax21:endTime>
           <ax21:originalValue>10.0</ax21:originalValue>
           <ax21:promotionName>0</ax21:promotionName>
           <ax21:recurCost>0.0</ax21:recurCost>
           <ax21:recurDate xsi:nil="true"/>
           <ax21:recurFlag>false</ax21:recurFlag>
           <ax21:recurInterval>0</ax21:recurInterval>
           <ax21:recurValue>0.0</ax21:recurValue>
           <ax21:startTime>2017-07-18T09:20:00.000+00:00</ax21:startTime>
           <ax21:uniqueTokenID>4574541</ax21:uniqueTokenID>
           <ax21:value>10.0</ax21:value>
        </ax21:responseBean>
        <ax21:resultCode>0</ax21:resultCode>
        <ax21:resultText>Successful</ax21:resultText>
     </ns:return>

The ns:return and ns:responseBean is what lets me get my last inserted result in XML. This works fine on postman, however, I am interested in returning all of the results given.

<CreditToken xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Status>True</Status>
<uniqueTokenID>4574541</uniqueTokenID>
<creditTokenName>FreeMoney</creditTokenName>
</CreditToken>

This is my return XML Value

E H
  • 1
  • 1
  • Can you post a masked version of the response you are using? Would be helpful to verify that portions of your code are correct. Also post the full code. What is xnList defined as? – canpan14 Jul 14 '17 at 12:54
  • @canpan14 please check on my updated code FYI – E H Jul 14 '17 at 13:18
  • Looks like there is some problem with the xml schema. I'm getting the error that ns:return is not bound (use any online xml validator and you will get the same thing). Not sure if that could be the cause of your error. Just pointing it out for now since I tried to load it in. Since it clearly looks correct its probably because I'm trying to call out to some schema/file or whatever that I can't hit. Or if you are seeing it also, something is wrong with the file in the first place. – canpan14 Jul 14 '17 at 13:38
  • @canpan14 check my return on the code edited above.I just need to return more than 1 response – E H Jul 14 '17 at 13:39
  • Wouldn't that just be because you are setting ct.whatever in a for loop? So whatever you set on the earlier loops are always going to be overridden by the last loop. – canpan14 Jul 14 '17 at 13:51
  • @canpan14 is their a way i can add the results in an array and loop them to get all he results> – E H Jul 15 '17 at 09:42
  • Of course. Just define a list at a high level, add to it as needed (info here) https://stackoverflow.com/questions/25962591/how-do-i-add-an-element-to-a-list-in-groovy . And then write it all to a file at the end. http://webservice-testing.blogspot.com/2011/10/create-file-groovy-soapui.html . – canpan14 Jul 16 '17 at 10:18

0 Answers0