Converting the Base-64 to String -Mock API - for SOAP request

Do you have any reference or Best practices which does something similar listed or converting base64 to String in Apigee.

I have SOAP input

1.Have a tag name say named as

<Load>This have base64 information</Load>

à I can arrive to this element thro X-Path. Looks like Apigee supports XPATH1.0 please correct me if wrong. Any updates on updated version of XPATH support than using Javascripts etc..

2.After extracting the Load information. convert the value from base64 to string in Apigee

à Need to understand best approach. I think we don’t have in build policy to supports this . When researching understand that such conversions may have some issues if using any libraries from javascripts or any other updates let me know. If you have such conversion which works fine let me know.

3. After converting base64 to String. Find out certain information if that exists in certain position after converting base64 to String à I need to use String position in Javascript.

4.Add the Base 64 (another Base64 information because of match) to required SOAP response element in response .--> I will have to try this to see if any error occurs due to adding base64 to SOAP response.

Let me know, if you have reference to DevJam with least similar approach or working model, which can help me out to know from both best practice perspective and avoid any limitations …

0 1 650
1 REPLY 1

You can do what you want.

This answer to your other question shows you how to extract information from an XML using ExtractVariables.

For decoding, Apigee has a base64decode function in Message templates. So you can do this:

<AssignMessage name="AM-DecodeBase64">
  <AssignVariable> 
    <Name>decoded</Name>
    <Template>{decodeBase64(encoded_value)}</Template>
  </AssignVariable>
</AssignMessage> 

...where encoded_value holds the thing you extracted from the prior step.