I have an api from where i got xml response in which garbage are also available which i do not need in my application.The response i receive are given below


<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="/v1/xsl/xml_pretty_printer.xsl" type="text/xsl"?>
<stores currentPage="1" from="1" to="10" totalPages="125" total="1243" queryTime="5.265" totalTime="5.289" canonicalUrl="/v1/stores?apiKey=3n4psbfccx9vgy86jmbget6k" partial="false">
    <store>
        <storeId>1118</storeId>
        <storeType>Big Box</storeType>
        <locationType>Store</locationType>
        <tradeIn/>
        <brand/>
        <name>HATO REY PR</name>
        <longName>Hato Rey</longName>
        <address>230 Calle Federico Costa</address>
        <address2>Hato Rey</address2>
        <city>San Juan</city>
        <region>PR</region>
        <fullPostalCode>00918-1355</fullPostalCode>
        <country>PR</country>
        <lat>18.42491</lat>
        <lng>-66.07171</lng>
        <hours>Sun: 11-7; Mon: 10-9; Tue: 10-9; Wed: 10-9; Thurs: 10-9; Fri: 10-9; Sat: 10-9; Sun: 11-7; Mon: 10-9; Tue: 10-9; Wed: 10-9; Thurs: 10-9; Fri: 10-9; Sat: 10-9</hours>
        <hoursAmPm>Sun: 11am-7pm; Mon: 10am-9pm; Tue: 10am-9pm; Wed: 10am-9pm; Thurs: 10am-9pm; Fri: 10am-9pm; Sat: 10am-9pm; Sun: 11am-7pm; Mon: 10am-9pm; Tue: 10am-9pm; Wed: 10am-9pm; Thurs: 10am-9pm; Fri: 10am-9pm; Sat: 10am-9pm</hoursAmPm>
        <gmtOffset>-5</gmtOffset>
        <language/>
        <services>
            <service>Apple Shop</service>
            <service>Geek Squad Services</service>
            <service>Car and GPS Install Services</service>
            <service>Marine Powered by Geek Squad</service>
            <service>Microsoft Windows Store</service>
            <service>Samsung Entertainment Experience</service>
        </services>
        <phone>787-764-4900</phone>
        <postalCode>00918</postalCode>
    </store>
    <store>
        <storeId>1090</storeId>
        <storeType>Big Box</storeType>
        <locationType>Store</locationType>
        <tradeIn/>
        <brand/>
        <name>RIO HONDO PR</name>
        <longName>Rio Hondo Mall</longName>
        <address>60 Ave Rio Hondo</address>
        <address2>Ste 60</address2>
        <city>Bayamon</city>
        <region>PR</region>
        <fullPostalCode>00961-3106</fullPostalCode>
        <country>PR</country>
        <lat>18.42205</lat>
        <lng>-66.16304</lng>
        <hours>Sun: 11-7; Mon: 10-9; Tue: 10-9; Wed: 10-9; Thurs: 10-9; Fri: 10-9; Sat: 9-9; Sun: 11-7; Mon: 10-9; Tue: 10-9; Wed: 10-9; Thurs: 10-9; Fri: 10-9; Sat: 9-9</hours>
        <hoursAmPm>Sun: 11am-7pm; Mon: 10am-9pm; Tue: 10am-9pm; Wed: 10am-9pm; Thurs: 10am-9pm; Fri: 10am-9pm; Sat: 9am-9pm; Sun: 11am-7pm; Mon: 10am-9pm; Tue: 10am-9pm; Wed: 10am-9pm; Thurs: 10am-9pm; Fri: 10am-9pm; Sat: 9am-9pm</hoursAmPm>
        <gmtOffset>-5</gmtOffset>
        <language/>
        <services>
            <service>Apple Shop</service>
            <service>Geek Squad Services</service>
            <service>Car and GPS Install Services</service>
            <service>Microsoft Windows Store</service>
        </services>
        <phone>787-522-0999</phone>
        <postalCode>00961</postalCode>
    </store></stores>

What i need is only name,country,region and city to display on screen. How can i achieve the described scenario.

Maha,

Two things.

1. If your post contains REAL data (phones, addresses, names, please, edit it to obfuscate this information.

2. You have an XML document, not a JSON document, so your POST title is misleading.

You can create code to parse your document yourself (a lot of work) or you can try to use one of the Forge components to parse it and extract the information you need.

You can start by looking to this document: https://success.outsystems.com/Documentation/How-to_Guides/How_to_parse_XML_files_with_XPath_expressions

Cheers.

Hi,

I think you only wanted to consume only selected data from this response. When we consume any Soap/Rest API, Outsystems automatically create entities/ structures to hold the values of that response. After that you can select only required values or can do mapping in another variable which have only attributes required by you.

Thanks.

vikas sharma wrote:

Hi,

I think you only wanted to consume only selected data from this response. When we consume any Soap/Rest API, Outsystems automatically create entities/ structures to hold the values of that response. After that you can select only required values or can do mapping in another variable which have only attributes required by you.

Thanks.

Hi,

I'm using the above web service but structure are not created. How can i proceed further?

Hi Maha,

You have xml in response that's why its not creating structure and only giving response in text. So now As mentioned by Eduardo already, "You can create code to parse your document yourself (a lot of work) or you can try to use one of the Forge components to parse it and extract the information you need."

So basically, you have to do it manually or can use some text to xml and then parser to parse the response.

Thanks.

vikas sharma wrote:

Hi Maha,

You have xml in response that's why its not creating structure and only giving response in text. So now As mentioned by Eduardo already, "You can create code to parse your document yourself (a lot of work) or you can try to use one of the Forge components to parse it and extract the information you need."

So basically, you have to do it manually or can use some text to xml and then parser to parse the response.

Thanks.

Hi, 

Using the document mentioned by Eduardo i'm successfully implement the structure and server action using my webservices. Now what should i do to proceed further?

and the server action are

but after publish when i open it in browser its give me error

Hi Maha,

It seems, as now you have successfully created server action to consume above web service response. 

For current error, please check service center logs and debug the server action to find out the possible cause of error.

vikas sharma wrote:

Hi Maha,

It seems, as now you have successfully created server action to consume above web service response. 

For current error, please check service center logs and debug the server action to find out the possible cause of error.

Hi Vikas,


When drop server action on main screen it's required xml which is mandatory but i don't know what can i insert here. Any idea??


Maha Rani wrote:

vikas sharma wrote:

Hi Maha,

It seems, as now you have successfully created server action to consume above web service response. 

For current error, please check service center logs and debug the server action to find out the possible cause of error.

Hi Vikas,


When drop server action on main screen it's required xml which is mandatory but i don't know what can i insert here. Any idea??


Hi Maha,

what this "StoreAction" do, if it is for processing the xml response , then you  need to pass xml response which received by API.


Hi Maha,

You need to pass the xml which is output of your api call, so before your server action you need to call you api which will return xml as output and it will become input for your parsing server action.

Regards,

Manish Jawla