Convert array to record list in C# (Integration Studio)

Convert array to record list in C# (Integration Studio)

  

Hi,


I'm trying to consume a soap web service via integration studio due to some limitations of soap.

If this web service is returning an array of a certain data type and I'm defining my output structure in the same way, but with record lists, how should I do the conversion?


Hovering over RLGBIGETNOSTROTRANSTypeRecordList would say : RecordList type RLGBIGETNOSTROTRANSTypeRecordList that represents a record list of GBIGETNOSTROTRANSType[]

But assigning ssoutput to output throws the error: 

Cannot implicitly convert type 'OutSystems.NssT24_ConsumeSoap.WebReference.GBIGETNOSTROTRANSType[]' to 'OutSystems.NssT24_ConsumeSoap.RLGBIGETNOSTROTRANSTypeRecordList'


Is there a straightforward way to do this? Thank you in advance.


Solution

Hi Lorena,

There's no easy way to do the conversion but manually. The steps to take:

  1. foreach over the list from the SOAP reference;
  2. Inside the foreach, declare a new variable of the type of Record of the OutSystems Record List, and assign it to a new record(null) (don't forget the null, or the Attributes won't be initialized!);
  3. Set the Attributes to the desired values (from the iterated list);
  4. Use the Append method of the Record List you're adding too to add the above variable.

An example from an Extension we created (also from SOAP), with a nested Record List:

foreach (MeterReading.RejectionMeterReadingResponseEnvelope_Portaal_Rejection PortaalRejection in rmRsp.Portaal_Rejection)
{
   RCNMMResponse_RejectionMeterReading_Content_ItemRecord Rejection = new RCNMMResponse_RejectionMeterReading_Content_ItemRecord(null);

   Rejection.ssSTNMMResponse_RejectionMeterReading_Content_Item.ssConnectionEAN = PortaalRejection.Portaal_MeteringPoint.EANID;
   Rejection.ssSTNMMResponse_RejectionMeterReading_Content_Item.ssProductType = PortaalRejection.Portaal_MeteringPoint.ProductType.ToString();

   Rejection.ssSTNMMResponse_RejectionMeterReading_Content_Item.ssTransactionMutationData.ssSTNMM_TransactionMutationData.ssExternalReference = PortaalRejection.Portaal_MeteringPoint.Portaal_Mutation.ExternalReference;
   Rejection.ssSTNMMResponse_RejectionMeterReading_Content_Item.ssTransactionMutationData.ssSTNMM_TransactionMutationData.ssTransactionReference = PortaalRejection.Portaal_MeteringPoint.Portaal_Mutation.Dossier.ID;

   foreach (MeterReading.RejectionMeterReadingResponseEnvelope_RejectionPortaalType PortaalSimpleRejection in PortaalRejection.Rejection)
   {
      RCNMM_RejectionRecord SimpleRejection = new RCNMM_RejectionRecord(null);

      FillRejection(ref SimpleRejection, PortaalSimpleRejection.RejectionCode.ToString(), PortaalSimpleRejection.RejectionText);
      Rejection.ssSTNMMResponse_RejectionMeterReading_Content_Item.ssRejectionList.Append(SimpleRejection);
   }

   sso_Response.ssSTNMMResponse_RejectionMeterReading.ssContent.ssSTNMMResponse_RejectionMeterReading_Content.ssConnectionList.Append(Rejection);
}
Solution

Hi Kilian,


Thank you. It worked :) 

Hi Lorena,

Great to hear! Happy coding :).