Integration

Get Involved. Join the Conversation.

Topic

    Khalid Abdul Salam
    Read and Parse SOAP Attachment FileAnswered
    Topic posted July 16, 2019 by Khalid Abdul SalamRed Ribbon: 250+ Points, tagged Integration, SOAP, xml 
    126 Views, 9 Comments
    Title:
    Read and Parse SOAP Attachment File
    Content:

    We've the following scenario:

    1. Oracle Fusion HCM Extract

    2. The extract output got deployed to UCM server

    3. Using SOAP web services of UCM, we were able to download the file of the extract using Soap UI tool

    4. at OIC, we did the same, consumed UCM SOAP web service, the response included the file reference at VFS

    5. Up to here, everything is fine. The issue that we're not able to read the file to parse its contents.

    Our target is to read the file data -which is xml- then parse it to DBaaS table.

    Version:
    19.3.1.0.0 (190624.1100.29532)

    Best Comment

    Hemanth Lakkaraju

    Option#1:

    After the soap invoke, use stage action and write operation with opaque schema (sample available in this blog post), provide the schema you have as sample. Map the soap invoke response element that has file reference with encodeReferenceToBase64 xslt function to stage write opaque element. This will write the file to stage in base64 format. Then use stage read with xsd you have and provide the same file details used for stage write. This should read the file and get you the xml content.

    Option#2:

    After the soap invoke, use stage action read with xsd you have. Use below combination of xsl functions parseEscapedXML(decodeBase64(encodeReferenceToBase64($fileReference))) on the file reference and use xsl:copy-of and map to the root element of stage read. $fileReference being the soap invoke response element that has the file reference. copy-of is not supported in XSL OOTB, so you have to import the xslt. This should read the file and get you the xml content

    Comment

     

    • Hemanth Lakkaraju

      What is the exact issue? Any error?

      • Khalid Abdul Salam

        The issue that I'm not able to read the contents of the SOAP attached file. The SOAP response includes the file reference, yet, how can I read its contents and parse it.

        • Hemanth Lakkaraju

          Do you know the structure of the file content? Is it a static/dynamic structure? If so, you can sample it using stage and read using stage.

    • Khalid Abdul Salam

      Do you know the structure of the file content?

      Yes, it's xml

       

      Is it a static/dynamic structure?

      static and have its xsd schema as well.

       

      If so, you can sample it using stage and read using stage.

      This's the part I'm not able to do. Can you please elaborate of how to sample it using stage.

      • Hemanth Lakkaraju

        Option#1:

        After the soap invoke, use stage action and write operation with opaque schema (sample available in this blog post), provide the schema you have as sample. Map the soap invoke response element that has file reference with encodeReferenceToBase64 xslt function to stage write opaque element. This will write the file to stage in base64 format. Then use stage read with xsd you have and provide the same file details used for stage write. This should read the file and get you the xml content.

        Option#2:

        After the soap invoke, use stage action read with xsd you have. Use below combination of xsl functions parseEscapedXML(decodeBase64(encodeReferenceToBase64($fileReference))) on the file reference and use xsl:copy-of and map to the root element of stage read. $fileReference being the soap invoke response element that has the file reference. copy-of is not supported in XSL OOTB, so you have to import the xslt. This should read the file and get you the xml content

    • Khalid Abdul Salam

      Hi Hemanth,

      Appreciating your support and sharing your experience.

      I chose to try to implement Option#2, yet, one step I wasn't able to implement, "map to the root element of stage read".

      What I did so far is:

      1. Trigger REST adapter to show the response, part of xml contents.

      2. Consumed the SOAP adapter to get the file as attachment

      3. Used Stage Activity: read, with file name from the SOAP response and directory any value.

      4. At REST response mapper, tried parseEscapedXML(decodeBase64(decodeBase64ToReference($fileReference))) where $fileReference at our case is:

      $ExtractAttachment/nsmpr0:GenericResponse/nsmpr0:Service/nsmpr0:Document/nsmpr0:File/nsmpr0:Contents

      I know that read activity has to be used, but I'm not sure how since there's No mapping for it.

      I've attached the response of SOAP containing the fileReference at Contents attribute.

    • Khalid Abdul Salam

      Hi Hemanth,

      When I use the schema file xsd with Stage Read Activity, No mapping entry at the mapper.

      If I used Stage Write Activity using the same schema, mapping entry does exist at the mapper and I'm able to map value to the root element.

      Any idea why using Read Activity, No entry at the mapper. I've attached the used schema file.

      • Hemanth Lakkaraju

        Ok. I need to check why the mapper is not available here. Probably stage read can only be made when you know the directory and file name where the reference is created. So. please try option#1 and see.

    • Khalid Abdul Salam

      Hi Hemanth,

      Trying Option#1 worked perfectly as you advised.

      Appreciating your support at this issue.

      Another point, I tried to check why Read Activity doesn't have mapper and I noticed that the entry of Read at mapper will only be available if the Read Activity has been preceeded by Write Activity or FTP Download.

      Thanks again..