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
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.
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.
- UCM Service returns a binary content
- 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
In Variable*: body
Replace node contents option is selected.
SaveFile Business Service
Service Type: Messaging Service
Request Message Type: Binary
Response Message Type: None
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.
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...
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"?>
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
In Variable*: body
Replace node contents option is selected.
and in the Stage above the Routing Action using Assign with the below properties
Any idea on how to just get the binaryContent rather than the enclosing tags also.
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
... 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...
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
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.
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!
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.