13 Replies Latest reply: Feb 12, 2014 6:37 AM by Adrian88 RSS

Save binary file using OSB file transport

899771 Newbie
Currently Being Moderated

Hi,

 

I have a requirement to save a file using osb file transport. Here is the scenario. Client will call the OSB Proxy service passing in the document_id. OSB then takes that document_id and pass it on the Oracle ECM service to get the document here is the output format of the UCM Service

 

 

<s:element minOccurs="0" maxOccurs="1" name="fileName" type="s:string"/>

<s:element minOccurs="0" maxOccurs="1" name="fileType" type="s:string"/>

<s:element minOccurs="0" maxOccurs="1" name="fileContent" type="s:base64Binary"/>

 

After that need to use the OSB file transport to save the file on the file system passing in the filename to be used. I am not able to save the the file using file transport. Here are the steps I have in a message flow of the proxy

 

1. Extract the document_id from the request

2. Created a request payload for UCM service

3. Use Service Callout to invoke a Proxy Service which is based on UCM Get File and pass the below input payload

<soap:Body xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">

<get:GetFileByID>

         <get:dID>{$dID}</get:dID>

         <get:rendition>{$rendition}</get:rendition>

</get:GetFileByID>

</soap:Body>

 

4. Now the UCM Proxy service returns the filename, fileType and fileContent

 

Am stuck on now how to save this content on the file system. I did created a business service of type message with input as Binary and Response as None. Am struggling to invoke this and pass the filecontent and name. What should I be using a Service Callout or Routing and how do I pass in the data to be saved. Any help is appreciated.

 

Any finally want to return a success or failure message to the caller.

 

Thanks

  • 1. Re: Save binary file using OSB file transport
    vladodias Guru
    Currently Being Moderated

    Hi,

     

    You have to assign the base64Binary content to a variable and then replace body contents with this variable when you route... The file name has to be passed as a transport header...

     

    Cheers,

    Vlad

  • 2. Re: Save binary file using OSB file transport
    899771 Newbie
    Currently Being Moderated

    Hi,

     

    I am able to save the file which in my case is a word document but when I open all I see is the binary content. The same content I assign to the body variable. Any idea what I am doing wrong. Here is what I have done.

     

    1. UCM Service returns a binary content
    2. Using Assign inside a Stage (Extract the binary data from the return element and assign it to fileContent variable):
    • Expression*: $body/get:GetFileByID/get:fileContent
    • Variable*: fileContent

     

    Dropped a Rotuing Node and then Rotuing Action which calls a SaveFile Business Service inside it. Inside the Routing Request Action I dropped a replace

    XPath*: .

    In Variable*: body

    Expression*: $fileContent

    Replace node contents option is selected.

    SaveFile Business Service

    Service Type: Messaging Service

    Request Message Type: Binary

    Response Message Type: None

    Protocol: file

    Prefix: test

    Suffix: .doc

    Request encoding: utf-8

    When I test I see a file created that is of type .doc as it's a word document. But when I open the word document it pops a message saying

    The file contains custom XML elements which are no longer supported by word. If you save this file, these custom XML elements will be removed permanently.

     

    I click ok on the popup and the word document opens but all it has is the fileContent data as is in binary format. I am expecting on saving the binaryfile it should open the actual word document. So wondering if there's anything I am doing wrong or the data that is sent to the business service is appeneded with extra xml tags etc.

     

    I used a log action and printed the actual contents of $body and $fileContent and they are the same as what's received from the UCM service but somehow while saving I am not able to save it as a correct document.

     

    Any help is appreciated.

     

    Thanks

  • 3. Re: Save binary file using OSB file transport
    vladodias Guru
    Currently Being Moderated

    Hi,

     

    I guess your problem is here...

    2. Using Assign inside a Stage (Extract the binary data from the return element and assign it to fileContent variable):


    Try to open the file content using Notepad++ or an Hex editor, you should see the word document signature...

     

    D0 CF 11 E0 A1 B1 1A E1ÐÏ.ࡱ.á


    But in your case you will probably see some extra xml tags that have to be removed...


    http://www.garykessler.net/library/file_sigs.html

    http://en.wikipedia.org/wiki/List_of_file_signatures


    Cheers,

    Vlad


  • 4. Re: Save binary file using OSB file transport
    899771 Newbie
    Currently Being Moderated

    I opened the file in Notepad++ and here is what I see extra xml tags. ontent from the return variable and assigning to body inside the rotuing action but looks below are also being tagged.

     

    <?xml version="1.0" encoding="UTF-8"?>

    <get:fileContent xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:get="http://www.stellent.com/GetFile/">

     

    </get:fileContent>

     

     

    Looks like $body/get:GetFileByID/get:fileContent is extracting the extra xml tags also rather than just the binary content. Inside the routing action I am using replace with the below properties

     

    XPath*: .

    In Variable*: body

    Expression*: $fileContent

    Replace node contents option is selected.

     

    and in the Stage above the Routing Action using Assign with the below properties

     

    • Expression*: $body/get:GetFileByID/get:fileContent
    • Variable*: fileContent

     

    Any idea on how to just get the binaryContent rather than the enclosing tags also.

     

    Thanks

  • 5. Re: Save binary file using OSB file transport
    vladodias Guru
    Currently Being Moderated

    Try $body/get:GetFileByID/get:fileContent/*

     

    Just append /* at the end of your expression...

     

    Cheers,

    Vlad

  • 6. Re: Save binary file using OSB file transport
    899771 Newbie
    Currently Being Moderated

    Hi Vlad,

     

    I tried that but now the body content is null it's not getting anything. Here is the log printing the data which is null as earlier without /* it was getting the content but along with extra xml tags. Jus curious if saving of binary files even works in OSB. We are calling UCM service that returns a binary data and when I try to save that as a file through OSB it doesn't work. Wondering if anyone have done that and if it even works as for sure for me it's not working. Will appreciate any help. I can share my project just to make sure I am not doing anything out of the way or any feedback on resolving this will be great.

     

    <Oct 11, 2013 9:00:40 AM CDT> <Error> <ALSB Logging> <BEA-000000> < [RouteNode1,

    null, null, REQUEST] $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$: File Content Body1212:>

     

    Created the file: C:\Users\AppData\Local\Temp\mdb_5109261254521277843xxx

    with a file size of -1 bytes

     

     

    Thanks

  • 7. Re: Save binary file using OSB file transport
    951803 Newbie
    Currently Being Moderated

    anyone I too am looking for a solution.

     

    Thanks

  • 8. Re: Save binary file using OSB file transport
    vladodias Guru
    Currently Being Moderated

    899771 wrote:

     

    ... Jus curious if saving of binary files even works in OSB...

    Yes, it surely works, I used that before. You just have to pass the binary content on the body of the Business Service...

     

    Build a test with a proxy service with inbound file routing to a BS to write the same file on other location... Once you get this working you can compare and see what's wrong with your use case...

     

    Cheers,

    Vlad

  • 9. Re: Save binary file using OSB file transport
    899771 Newbie
    Currently Being Moderated

    Hi Vlad,

     

    I have uploaded a sample project that I am using but it's not working I tried all your suggestions. Do you mind taking a look at it and see what's wrong with ti. Please download osb.zip from

    http://snk.to/f-cdtigflj

     

    The zip contains:

    binarycontent-worddocumet.txt  (sample binary contetn that is a word document)

    sbconfig.jar   (osb project)

    soapui-payload.xml   (soapui payload used for test)

     

    osb project have 2 Proxy services

     

    NewFileSavePS.proxy  which uses jca business service to save the file and this works fine

    FileSavePS.proxy   which uses OSB File Transport business service and this is what is not working

     

     

    Will be great if can check what am I doing wrong because in my case UCM Service is returning a binary content that I am trying to save not reading a file and saving it. I am posting through SOAPUI using OSB File Transport does create a word document but when opening it pops up error and once it is opened it's just the content not the actual document as saved by jca service.

     

    Thanks

  • 10. Re: Save binary file using OSB file transport
    vladodias Guru
    Currently Being Moderated

    I'm always happy to help people that follows the forums etiquette... However...

  • 11. Re: Save binary file using OSB file transport
    Riaan.Ingram Explorer
    Currently Being Moderated

    Have waded into this thread late, but maybe this blog post could help you: Oracle Service Bus: Attachment Handling using Oracle Service Bus (OSB). It shows how to convert binary to text in OSB.

     

    Hope it helps!

  • 12. Re: Save binary file using OSB file transport
    899771 Newbie
    Currently Being Moderated

    Thanks Riaan, converting binary to text is not an issue, the issue I am facing is saving that binary content to a file i.e. if .doc, .gif or ,pdf once saved should open respective documents. I tried all the suggestions posted so far but none works. Any suggestions would really help.

     

    Thanks

  • 13. Re: Save binary file using OSB file transport
    Adrian88 Newbie
    Currently Being Moderated

    I have the same problem... I use JCA adapter and deploy it on OSB and everything works fine!

     

    Thanks

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points