Integration

Get Involved. Join the Conversation.

Topic

    Mark Chappell
    Integration calling REST Service
    Topic posted March 27, 2019 by Mark ChappellBronze Medal: 1,250+ Points, tagged Integration, Orchestration, REST 
    276 Views, 27 Comments
    Title:
    Integration calling REST Service
    Summary:
    My Integration is not returning any data from the REST Service
    Content:

    Hi,

    I'm after some help with my Integration which calls a REST Service. I am new to REST services, having built a few Integrations utilising flat files and the FTP Adapter and SaaS ERP Adapter.

    So, I have a OVBCS App, very simple, which I have called via its REST Service, from SOAP UI. Using GET Method I can return all the records contained in the 1 business object in the App, and using PATCH I can update a record from SOAP UI.

    However, when trying to call the REST Service from my orchestration Integration, using GET method I don't see any data returned.

    has anyone done this before, anyone able to offer any help with this deign pattern / integration?

    thanks

    Mark

    Comment

     

    • BlueBell

      HI ,

      Please check https://integration-soa.home.blog/2019/03/11/oicrest-service-exposed-in-oic/

       

      Aslo please verify  if the below flag is checked while selecting GET method

       

    • Cesar Tepetla Corte

      Hi Mark,

      Are you trying to return an answer after patch? or simply want to return the content with a GET operation.

      Let me know your comments.
      Regards.

      • Mark Chappell

        Hi,

        thanks for the reply. I am  for now, simply trying to return the content with a GET - I will expect many objects as the app contains many rows. I will then want aim to map the json payload to a csv schema and write the data to a flat file.

         

        Thanks

        Mark

    • John Graves

      Mark,

      Calling VBCS Business Objects via REST services is a common pattern.

      As Hemanth mentioned, perhaps you can give a bit more detail on the problem/errors you are seeing.

      Does the connector configuration work?  Did you configure the reply payload properly?  If you take the output of your REST test and use it as a sample JSON payload in your response message, it should work perfectly.

      If you want to share the VBCS / OIC assets, I can help you get them connected.

      -John

    • Mark Chappell

      Hi 

      thanks for the replies.

      I've attached a few screen shots to highlight my issue... 

      My VB App (a very basic Classic App) has the following Data API listed;

      https://XXXXX.integration.ocp.oraclecloud.com/ic/builder/design/NHSSC_MO_Emulation_App_01/1.1/resources/data/InterfaceRegister2

      and using this REST URL, I can GET data and update using PATCH, from SOAP UI. - see atached.

      In my simple Integration I have defined the Connection, URL as; - see atached.

      https://XXXXXX.integration.ocp.oraclecloud.com/ic/builder/design/NHSSC_MO_Emulation_App_01/1.1/resources/data

      I've used basic authentication with my OICS (IDSC) username and paasword - which I use to access my VB Application.

      My Integration Flow, is very simple. - see atached. I invoke my REST connection - see atached, then I Map to a Stage Action to Write the data to a file (based on a csv schema I uploaded). Then I Read the File as a stage action, and as a Test for each record I read I email the ID value to myself. So I expect, several emails to be sent. The Invoke REST Connection is configured thus;

      Endpoint relative URI = /InterfaceRegister2

      In the Response I have uploaded a sample json schema as output I received from SOAP UI - see atached.

      However when I run the Integration I the integratoin flow - see atached, seems to read nothing from the REST connection, and I get the following message;

      minOccurs not satisfied. 
      minOccurs="1" not satisfied for the node "<element name="readRecordSet">". Loop terminated with cardinality "0". 
      Insufficient or invalid data. 
      Please correct the NXSD schema. 
      Error while translating message to the mentioned format. 
      Please make sure that the file content conforms to the schema.

      any help in this, is greatly appreciated guys.

      thanks
      Mark

      • Mark Chappell

        Sample json

      • Mark Chappell

        sampls csv

      • Hemanth Lakkaraju

        I don't see sample json and csv attached. This screenshot shows REST invoke failed while the one in attached document shows the REST invoke passed, stage write passed but stage read failed.

        Couple of observations/questions:

        1. SOAPUI has endpointURI ending wiith /InterfaceRegister2 while the REST is configured with /InterfaceRegister2/4.

        2. What is the REST response configured with? JSON as seen in SoapUI?

        3. What is Stage Write and Read configured with - both with csv?

        4. What is the request mapping for Stage Write?

        • Hemanth Lakkaraju

          The json shows a single entity - which means only one line of csv will be written and subsequently one read should be happening. Can you enable trace with payload for the integration and attach the flow logs to figure out what's going wrong?

          • Mark Chappell

            I will attach logs yes. Also as you can see, I've now answered your questions in further detail.

            Also, the JSON file I attached in the REST invoke response, does only show 1 entity - I am not sure how many entities I will end up having in the VB App, so not sure how many entities I want to return from the REST call? Is the GET method incorrect in this use case scenario? Am I able to return multiple entries from the VB App and so write multiple lines to say a flat file?

             

            thanks

            Mark

            • Hemanth Lakkaraju

              Looking at all the data and the logs

              <executeResponse xmlns="http://xmlns.oracle.com/cloud/adapter/REST/GetAllData_REQUEST/types">[[
                 <response-wrapper xmlns="http://xmlns.oracle.com/cloud/adapter/REST/GetAllData/types">
                    <links>
                       <rel>self</rel>
                       <href>https://nhsscoicmodeloffice-supplychainnhs.integration.ocp.oraclecloud.com:443/ic/builder/design/NHSSC_MO_Emulation_App_01/1.1/resources/data/InterfaceRegister2</href>
                       <name>InterfaceRegister2</name>
                       <kind>collection</kind>
                    </links>
                 </response-wrapper>
                 <HTTPHeaders/>
              </executeResponse>

              The JSON used for REST invoke is for single element and the invoke response seems to send data for ALL and hence there is a mismatch in response structure causing NO DATA to be written to Stage and subsequently Stage read is failing.

              I am not sure how many entities I will end up having in the VB App, so not sure how many entities I want to return from the REST call?

              It depends on you use case. If you want to fetch all data and write a single file with all details, the response you see in SoapUI call screenshot is the one you need to configure and the endpoint should be just /InterfaceRegister2.

              Is the GET method incorrect in this use case scenario?

              This is perfectly fine! As long as you are just reading the data.

              Am I able to return multiple entries from the VB App and so write multiple lines to say a flat file?

              Yes! It's just a mis-configuration in current call. The endpoint is /InterfaceRegister2 and the JSON specified in response is for /InterfaceRegister2/NUMBER causing the issue.

              • Mark Chappell

                Hi Hemanth,

                so - "The JSON used for REST invoke is for single element and the invoke response seems to send data for ALL and hence there is a mismatch in response structure causing NO DATA to be written to Stage and subsequently Stage read is failing."

                I have now changed the /InterfaceRegister2/5 which would only return 1 entity - and so match the JSON example uploaded for the REST invoke?

                I've re ran and get the same error;


                Integration Run: start Time: 2019-03-28T17:33:57.627+00:00 | 6400007

                 

                • Hemanth Lakkaraju

                  Yes. The write is good.

                     <nsmpr2:TestRecordSet>
                        <nsmpr2:TestRecord>
                           <nsmpr2:S_NO>5</nsmpr2:S_NO>
                           <nsmpr2:Source_System_Name>Order Tracker</nsmpr2:Source_System_Name>
                           <nsmpr2:Destination_System>OM</nsmpr2:Destination_System>
                           <nsmpr2:Application_Name>Model Office</nsmpr2:Application_Name>
                           <nsmpr2:Application_Category/>
                           <nsmpr2:Interface_ID_IC_>INT0005</nsmpr2:Interface_ID_IC_>
                           <nsmpr2:Use_Case_ID>UC09_OT_EI_OM</nsmpr2:Use_Case_ID>
                           <nsmpr2:Interface_Name_IC_Use_Case_Name>Create_Sales_Order_OM</nsmpr2:Interface_Name_IC_Use_Case_Name>
                           <nsmpr2:Interface_Description_IC_>Create sales order at OM. This comes for Order tracker. This interface creates the sales order at OM. File from Order tracker is polled, parsed, transformed and sales order is created.</nsmpr2:Interface_Description_IC_>
                           <nsmpr2:OIC_Reference_Details/>
                           <nsmpr2:Requested_By/>
                           <nsmpr2:Requested_Date/>
                           <nsmpr2:Status/>
                           <nsmpr2:AOIC_Status/>
                        </nsmpr2:TestRecord>
                     </nsmpr2:TestRecordSet>

                  Read failed probably due to one of the empty elements are marked mandatory or read csv specifies first row as headers. Can you log the csv data from write response using decodebase64(encodeReferenceToBase64($WriteResponse/FileReference)) and see if it has only data lines or header lines as well?

                  • Mark Chappell

                    Hi Hemanth

                    I've added a log action after the Write File stage file action and added the following as the source of the log message;

                    oraext:decodeBase64(oraext:encodeReferenceToBase64($WriteFile/nsmpr6:WriteResponse/nsmpr5:WriteResponse/nsmpr3:ICSFile/nsmpr3:FileReference))

                    I can see in teh Activity Stream, the following listed the Log action... 

                    Logger - Fri Mar 29 10:06:14 UTC 2019 - 5,Order Tracker,OM,Model Office,,INT0005,UC09_OT_EI_OM,Create_Sales_Order_OM,"Create sales order at OM. This comes for Order tracker. This interface creates the sales order at OM. File from Order tracker is polled, parsed, transformed and sales order is created.",,,,, - LogWriteFile.

                    again I've attached the activity log (start Time: 2019-03-29T10:06:11.106+00:00 | 6800007) and a screen shot of the integration flow from the monitoring page.

                    thanks
                    Mark

                  • Mark Chappell

                    Activity Stream Log attached

              • Mark Chappell

                activity log

              • Mark Chappell
          • Mark Chappell

            Integration Run: start Time: 2019-03-28T17:15:21.557+00:00   Instance ID: 6800006

            Diagnostic Logs attached

          • Mark Chappell

            activity logs attached

    • Mark Chappell

      Sample JSON 

    • Mark Chappell

      csv schema

    • Mark Chappell

      Hi Hemanth, 

      my comments / answers are below;

      I don't see sample json and csv attached. 
      **apologies - have attached now.

      This screenshot shows REST invoke failed while the one in attached document shows the REST invoke passed, stage write passed but stage read failed.
      **this screen shot showing rest invoke added in error, but shows the overall intended flow of the Integration.
      **the one in the attachment, shows my actual current error at stage read failed.

      Couple of observations/questions:

      1. SOAPUI has endpointURI ending wiith /InterfaceRegister2 while the REST is configured with /InterfaceRegister2/4.
      ** I've tried both combinations in SOAP UI and I get all data returned with /InterfaceRegister2 and then specific records with /InterfaceRegister2/NUMBER. I've tried both when configuring the REST invoke in my integration - but get nothing returned.

      2. What is the REST response configured with? JSON as seen in SoapUI?
      **Yes, with JSON responce from SOAP UI - I record, as attached SampleVBAppRESTResponse.txt - screen shot as attached RESTresponseConfig.JPG

      3. What is Stage Write and Read configured with - both with csv?
      **yes, csv schema as in csv file attached - InterfaceRegisterSchema.csv

      4. What is the request mapping for Stage Write?
      **maps from the GetAllData REST invoke to the WriteFile stage file action, as defeined in attached READfileMapping.JPG

      thanks 
      Mark

    • Mark Chappell

      RESTresponseConfig.JPG

    • Mark Chappell

      READfileMapping.JPG

    • Mark Chappell

      Hi Guys

      just to update, as you have kindly offered to help - I have changed my Integration, so after I write the response from my REST service to the OICS internal directory, I now write the output via an FTP Adapter to a SFTP server. This is a success now, and I can see the file output in my SFTP server.

      One question remains though, in my example I have defined the REST endpoint as " /InterfaceRegister2/5 " which would only return 1 entity, id of 5

      How do I set up my integration, if I want to write out to my file via the FTP adapter ALL the records returned from my REST web service - when I do not know how many records that could be? in my example I am calling via the REST api my Visual Builder Application business object, and i will not knw how many records this will hold - but would want to return all records and write to a file.

      Is this possible? 

       

      thanks

      Mark