Tuesday, September 27, 2011

Base64 encoding in Oracle BPEL 11g

Sometimes in SOA Suite 11g you need to pass binary data to a web service reference. In SOA Suite 11g there is no standard XSLT or XPATH function which you can use. But in BEPL you can use embedded java, like Sudheer already blogged about. He used the com.collaxa.common.util.Base64Encoder class which does not exists in 11g so I will use the new oracle.soa.common.util.Base64Encoder class.

As input I will retrieve some xml from the inputVariable, get the xml as a string, encode this and set the value to a base64Binary variable.

14 comments:

  1. Would a custom XPath function also be possible? In this case you can implement it at one place and use it everywhere !

    ReplyDelete
  2. Hi,

    That should be possible only you need to find out what the input is like a string , xml or binary.

    and need to deploy it on the soa server and to every developer pc. Sometimes this is too much

    thanks

    ReplyDelete
  3. Thank you for this useful post. What other imports are required besides oracle.soa.common.util.Base64Encoder class. I get failure in compile execlets of bpel process.

    ReplyDelete
  4. Hi,

    I use the full path and don't use imports.

    You can check my code for all the classes.

    thanks

    ReplyDelete
  5. Right, it works now. Thank you for your suggestion.

    ReplyDelete
  6. Hello Edwin,

    nice article which help me to decode base64 in Oracle BPEL. At the moment I have problem to access the right Part of Variable. It seems that the XPath is not relevant. I got no more information in Oracle Support Web, may be you have an idea:
    getVariableData("inputVariable", "payload", "//ns1:document/ns1:Metadata");

    System print output:


    ?
    ?
    ?
    ?
    ?
    ?
    ?
    ?
    ?


    ?
    ?

    Thanks
    Marcel

    ReplyDelete
  7. Hello Edwin,

    it's me once again. I do some research and an output via convertDomNodeToString and the result shows that getVariableData works fine.
    The problem is the getDocument function. It seems that this get the whole variable data. I hope to find a solution.

    Thanks
    Marcel

    ReplyDelete
  8. Hi,

    Can you test getVariableData in bpel first, there must somewhere a mistake.

    thanks

    ReplyDelete
  9. Hi Edwin,

    getVariableData seems to work fine. I print out the data with convertDomNodeToString and it looks good. After "getDocument" the variable contains the whole variable data.

    Regards
    Marcel

    ReplyDelete
  10. String System_base64string = ((oracle.xml.parser.v2.XMLElement)getVariableData("InvokeSyncReadFile_SynchRead_OutputVariable","opaque","/ns3:opaqueElement")).getFirstChild().getNodeValue();

    This is returning XML document from First node. But my requirement is to extract the
    XML document from second child element.

    For Ex:





    Then I need output from tag.
    Please help me on this.

    ReplyDelete
  11. Are there plans to put the SOA component into JDeveloper 11.1.2?

    Thanks!

    ReplyDelete
    Replies
    1. hi,

      No. you need to wait at least a year for 12c , 11gR2 is an ADF patch release which stills run on wls 10.3.5. Oracle uses this to test JSF2.0.

      thanks

      Delete
  12. Hi Edwin Biemond,

    When I try to decode with following code snippet:








    I am getting class cast exception.

    ReplyDelete
    Replies
    1. Hi

      Can you escape your xml code, so I can see what your are doing.

      thanks

      Delete