Returning DataSet from WCF

Returning DataSet from WCF

Returning DataSet from WCF
1)      Because a DataSet is an object, it’s interpreted by the Outsystems Platform as a string value. Also, it would not be a good idea to send an object through a web service in any case.
2)      To successfully return the DataSet from the WCF Service to the Outsystems platform we first need to convert it into an XML string value.

3)      Remember to also give your DataSet and DataTable proper names. This will form the DataSet (Parent Node) and DataTable (Child Nodes) of your xml string.

4)      Here is a sample of the XML string that returns from the WCF service. You will notice that there is no XML declaration in the XML string. We will add this later.
5)      Now that we are returning an XML string instead of an Object from the WCF service we can go ahead and add the Service Reference to the eSpace.


6)      Next we will have to create a structure that EXACTLY matches that of the returning data


7)      We also need to create a new user Action where we will format and bind the XML string to the newly created Record List.


·         groupExtension: Input Parameter (Argument specified to return only certain results)
·         InboundCallsRecordList: 
                   o   Data Type:  Record List
                   o   Record Definition: InboundCallActivity.
                         NB! The Record Definition needs to be exactly the same as the returning XML string.
                        ·         XML: Output Parameter
                   o   Data Type: Text
8)      Let’s create the rest of the user Action.


8.1) Web reference method that will request the Inbound calls for a specific extension and return our XML string.
8.2) Next we need to assign the XML local variable to the output parameter from the getInboundCallActivity web reference method.

                    We also need to add the XML declaration to the XML string at this time.
                                      "<?xml version=""1.0"" encoding=""UTF-8""?>"
                    Alternatively you could add the XML declaration in the WCF service.

              8.3)  Finally, we will need a component available in the forge called XML Records.
·         Add a reference to the XmlRecords and add the XmlToRecordList to the action.
·         We will need to specify a few parameters XmlToRecordList
                              o XML: XML (Local Variable)
                              o RecordList: ToObject(InboundCallsRecordList) – Input Parameter.
                                       §  We need the ToObject function to cast the Record List to an object.
            9)      That is pretty much it. You can now use this action in any part of your application.
I hope that this will help someone that had the same issues as me.

Have fun
FC Malan