OrangeScape Developer Community

A community for Application Developers on OrangeScape's Platform-as-a-Service


You can integrate with other systems from OrangeScape with webservices.  

Sometimes the output of the webservices may not be direct, instead they might have hierarchy in the structure.  Consider this, we will use the same service http://www.oorsprong.org/websamples.countryinfo/CountryInfoService...., we will try to find the countries where a certain currency will be accepted..

For this we will have two models with one to many relationship.  Currency and Country.  (since the same currency can be used in more than one country)

if you observe the Webservice output, you can see that it has a xml structure.  now when you request will have more than one response values, it can grouped in two ways.
for example, the output can be in two different ways.

 response 1:

<currency>
        <country>
                <code>GU</code>
                <name>Guam</name>
        </country>
        <country>
                <code>PW</code>
                <name>Palau</name>
        </country>
        <country>
                <code>EC</code>
                <name>Ecuador</name>
        </country>
        <country>
                <code>TL</code>
                <name>Timor-Leste</name>
        </country>
</currency>
   response 2:

<currency>
        <countries>
                <country>
                        <code>GU</code>
                        <name>Guam</name>
                </country>
                <country>
                        <code>PW</code>
                        <name>Palau</name>
                </country>
                <country>
                        <code>EC</code>
                        <name>Ecuador</name>
                </country>
                <country>
                        <code>TL</code>
                        <name>Timor-Leste</name>
                </country>
        </countries>
</currency>


These 2 responses require two different configs.
Lets see for the first one response 1: .

 

 

As you can see in the config, you have to add a hierarchy.  Give the node name from the response xml which it has to map for this hierarchy, which you have created now.  Now map this to the model in which you want the data from this to be stored. and use add new parameter to map the fields in the model to the tags in the response xml.
Now in runtime if you call this action, based on the number of countries returned, that many number of country records will be created for the model country with a one to many relationship with that particular currency model's record.....

Now let's see what if the response was something like response 2:

Now from the above example we saw that for hierarchy we have a model which we map and get the values. But in response 2 we have one more hierarchy in the middle <countries> .  Does that mean we need to have an empty model named countries with relations to country and currency?!! 

Actually no.  When defining the hierarchy of the output to receive in OrangeScape, you can add an empty hierarchy and leave it without mapping it to any of the models, and then create another inner hierarchy, to which you can map and receive the results.  Once you do empty hierarchy, the relationship which shows over there will also show for the inner hierarchy which you have created.  so you don't need to have another model in between.  

You can see the config for the second response below:

 

Views: 228

Comment

You need to be a member of OrangeScape Developer Community to add comments!

Join OrangeScape Developer Community

Comment by Kamal.S on March 27, 2014 at 3:35pm

© 2017   Created by OrangeScape Technologies.   Powered by

Badges  |  Report an Issue  |  Terms of Service