Search code examples
web-servicessoajdeveloper

Oracle 11g SOA Suite Database adapter accepting list as input


I would like to be able to create a service with Oracle 11g SOA Suite Database Adapter that takes a list as input. So I would like to be able to feed the getCountries operation a list of countryId.

I found this link. It works but it breaks on a parameter that contains the delimiting character so it's not ideal.

I've been trying to use a function that has a collection as input and as output and use for-each constructs to do the mapping. But can't get it to work. I'm not certain if DBAdapeter can handle this.

Has anybody tried something like this?


Solution

  • You can do that - make that Parameter (pCountryList) a string.

    To make it work you need to supply the list as a valid XML document

    <?xml version="1.0"?>
    <Countries>
    <Country><ID>MyCountyID 01</ID></Country>
    <Country><ID>777</ID></Country>
    <Country><ID>ID__3</ID></Country>
    </Countries>
    

    Then you need to create a query with a subselect that transforms the XML into rows (each row containing one country ID from the XML)

    SELECT * FROM MyTable WHERE CountryID IN
    (
    SELECT extractvalue(column_value, '/Country/ID') ContryID
    FROM TABLE(XMLSequence(XMLTYPE(:pCountryList).extract('/Countries/Country'))) t);
    

    This query takes a list of country IDs (packaged into an XML string) and can be used with Oracle 11g SOA Suite Database Adapter.