tutorial

  1. Home
  2. docs
  3. tutorial
  4. 51. How to pass raw data to custom class for processing with custom code?

51. How to pass raw data to custom class for processing with custom code?

 

Learning Objective:-

This unit describes :-

  1. How to pass raw data to custom class for processing?

 

1. How to pass raw data to custom class for processing?

When we get unstructured data which are not xml, csv or json at that time we need to create custom class . The data can be raw text and do not follow any format. Therefore we cannot parse and create messages. In this case, we pass the raw data to the customer class and the custom class will do everything itself e.g. parse the data, create and post messages.

The unstructured data are for example binary data, windows ini file etc.

2. The procedure to pass raw data to custom class for processing with custom code:-

The procedure is given below with an example:-

 

1. Create Integration:-

2. Create Interface:-

 

  • In Runtime Configuration Section of Interface page we need to select two things which are shown in picture given below :-
  1. We need to tick Custom Processing.
  2. And need to enter Custom Processing class.

 

3. Create custom class :

  •  The custom code is given below to pass raw data to custom class:-

 

public with sharing class RawDataCustomProcessing extends AbstractIntegrationV3 {

public override String messageProcessing(){

System.debug('>>>>>>RawDataCustomProcessing>messageProcessing>dtoRequestBody: '+dtoRequestBody);

//do raw data in dtoRequestBody

return 'ok';

}

public override IServicesUtil.IMessageResult createMessage(AbstractIntegrationV3.DtoRequestBody dtoRequestBody,

AbstractIntegrationV3.DtoStructure dtoStr){

return null;

}

}

 

  • We can use dtoRequestBody to do the complex logic that payload defined dtoRequestBody structure is as below:-
global class DtoRequestBody{
global String mode{get;set;}//Synchronous,Asynchronous
global String integration{get;set;}//integration name or integration id

global String iinterface{get;set;}//interface name or interface id

global String transferId{get;set;}

global String runtimeParameter{get;set;}//runtime interface field value to overwrite real interface in memory

global String payloadFormat{get;set;}//xml/json

global String payload{get;set;}//data to be integrated

}

4. Call Webservice:

 

  • After call Webservice, it will pass raw data to messageProcessing method.
  • After that, user can use this raw data to do with their complex logic that they want.

 

Was this article helpful to you? Yes No

How can we help?