Question

REST integration (App10)

  • 29 June 2021
  • 6 replies
  • 1031 views

Userlevel 1
Badge +4

Hello,

We are trying out some interface options which we expected to be available in REST integrations/JSON (since similar options available in IFS Connect/XML)  but could not make them work. Can someone help me to find out best way to handle these implementations?

  1. Sending and receiving binary files as fields in a JSON Input/Output.

In IFS Connect we could model document with several fields together with fields of type Binary. When XML is transferred, framework automatically convert binary value to base64binary text and for input convert back from base64binary text.

We have more options in modeling in REST, but none of them allow us to transfer some data together with binary objects at same time using one endpoint.

Example models I try out:

action GetDocfile {
   initialcheck none;
   parameter Contract   Text;
   parameter LotId      Text;
   parameter File       Binary;
}

action GetDocfileByStream {
   initialcheck none;
   parameter Contract   Text;
   parameter LotId      Text;
   parameter File       Stream;
}

action GetDocfileByText {
   initialcheck none;
   parameter Contract   Text;
   parameter LotId      Text;
   parameter File       LongText;
}

In this last one I try to convert CLOB to BLOB in PLSQL (Utility_SYS.Convert_Base64_Clob_To_Blob(file_)).

None of the options worked without errors for somewhat large files (example: PDF attachments). What is the best way to handle this kind of interface implementation in REST?

There seems to be a workaround that need to access 3 endpoints and use data from each other. But that kind of solution is not easy to implement in external systems.

  1. In IFS Connect we could create document structures as we need for XML and used them in input and output to interface methods. Only way we seems able to do that in REST implementations is using structures. But this implementation add unnecessary level and data to JSON.

Example:

We need request:

{
"Contract": "It is a Text",
"PartNo": "It is a Text",
"VendorNo": "It is a Text",
"ManufacturerId": "It is a Text",
"ConfigurationId": "It is a Text"
}
 

with response:

{
"Contract": "It is a Text",
"PartNo": "It is a Text",
"VendorNo": "It is a Text",
"VendorPartNo": "It is a Text",
"VendorPartDescription": "It is a Text",
"ManufacturerNo": "It is a Text",
"ManufacturerPartNo": "It is a Text",
"CommGenDescription": "It is a Text",
"Cost": "It is a Text"
}

Model implemented like following:

action TDMUpdatePart Structure(ReturnStructure) {
   initialcheck none;
   parameter SuppManuDetails Structure(DatasetStructure);
}

structure ReturnStructure {
   attribute Contract                Text;
   attribute PartNo                  Text;
   attribute VendorNo                Text;
   attribute VendorPartNo            Text;
   attribute VendorPartDescription   Text;
   attribute ManufacturerNo          Text;
   attribute ManufacturerPartNo      Text;
   attribute CommGenDescription      Text;
   attribute Cost                    Text;
}
structure DatasetStructure {
   attribute Contract         Text;
   attribute PartNo           Text;
   attribute VendorNo         Text;
   attribute ManufacturerId   Text;
   attribute ConfigurationId  Text;
}

 

But in JSON we get extra data than expected. There seems no way to prevent this

JSON we get:

{
   "SuppManuDetails": {
      "Contract": "It is a Text",
      "PartNo": "It is a Text",
      "VendorNo": "It is a Text",
      "ManufacturerId": "It is a Text",
      "ConfigurationId": "It is a Text"
   }
}

How can we create a JSON where we have data fields in first level?

 

  1. In IFS Connect web service implementation we had option to create data structures very easily for tables/views exist in database using advance query view and also had option to get query methods automatically generated from framework. This reduce lot of development time. I could not find similar option in REST implementation. Is there some way to handle similar implementation in REST?

Best Regards

 

Sandaruwan Wijenayake

 


This topic has been closed for comments

6 replies

Userlevel 6
Badge +15

Hi @Sandaruwan,

 

Regarding Question #1,

Did you have a look at the approach used in CreateAndImportDocument.svc/EdmFileSet for DOCMAN?

We could send the binary file as a byte stream in the body and the other parameters in the request URL path as follows,

https://<SERVER>:<PORT>/int/ifsapplications/projection/v1/CreateAndImportDocument.svc/EdmFileSet(DocClass='100',DocNo='1000016',DocSheet='1',DocRev='A1',DocType='ORIGINAL',FileNo=1)/FileData

 

I have attached my postman collection for CreateAndImportDocument.svc projection endpoint in the below article,

 

Further, I have initiated a topic regarding the Integration Upgrade Strategy,

 

Hope this helps :blush:

 

Cheers !
Dhananjaya.

Userlevel 3
Badge +6

Hi Sandaruwan 

For your 2nd query,
you can use below action in your projection.

action TDMUpdatePart Structure(ReturnStructure) {
initialcheck none;
parameter Contract Text;
parameter PartNo Text;
parameter VendorNo Text;
parameter ManufacturerId Text;
parameter ConfigurationId Text;
}

This will generate your desired json request payload. 

We need to define structures in actions when we need to handle complex json objects where there could be multiple levels of data in the payload.

Regards
Praveen 

Userlevel 1
Badge +4

@praveen.geevinda 

Thank you very much for the feedback. Your solution can be used in only some situations. Example I gave is simple one but most of the time structure involve in inputs. Also there is a inconsistency in returning data as in return we can use only structure for return data. This is why I think it is not a good idea to have that structure information in JSON we get. We need only the data in correct levels of structure in most of the interfaces. Also if external system already defined the JSON we have issues to create similar JSON and will have to go through unnecessary conversions.

Also it seems Plsqlap_Document_API.To_Json method also add this extra level. 

Maybe we need an option to decide if we need this extra information or not? Hope framework will support something like that.

 

@dhlelk 

Thank you for your feedback too. Question here mainly to understand what framework supported. I can model as I mentioned so I was expecting them to work. I am investigating further. I expect to have binary fields converted automatically in JSON to base64binary text as same as we had in IFS Connect web services. We have some external systems where they have JSON with bas64binary text in JSON and I could not find a way to use such files.

 

 

Userlevel 1
Badge +4

@dhlelk

I tried to check the solution you suggested and it looks to be very specific for document management system and if we reuse that then we can only add files to IFS Document Revisions. 

What I am looking for is a general solution independent from document management.

Also I have a question now how we an handle file transfers in synchronous messages with file reader/file sender. It seems all Binary and Long Text implementations convert in to a some temporary lob id. This will not work if we have a JSON file through a file reader.

 

Anyone tried binary file transfers with file reader/sender?

 

Userlevel 6
Badge +15

Hi @Sandaruwan,

 

I tried to check the solution you suggested and it looks to be very specific for document management system and if we reuse that then we can only add files to IFS Document Revisions.

Yes true, but we can get the java implementation code to write the BLOB file into the database.

 

Cheers !
Dhananjaya.

Userlevel 6
Badge +15

Tagging #IFSACH #ACHTECH
CC: @Yasas Kasthuriarachchi