Get Engaged – HP Marketing Optimization Blog
HP Marketing Optimization is centered on the most comprehensive set of customer experience and engagement technologies in the marketplace. Join the conversation and get engaged.

Digital Marketing: Leveraging the HP MediaBin APIs: Part 4 – Asset Metadata

This is the fourth post in a blog series on Leveraging the HP MediaBin APIs.


mediabin part 4.jpg

In this post, we’ll explore the MediaBin APIs used to retrieve metadata on assets.  These will form the basis of any code you will write for the following: to extract metadata from assets in MediaBin, to display to a user, to become part of a report or to feed into another process. 


In a typical coding exercise first isolate the set of assets you wish to work on, perhaps through a collection returned from the search APIs we discussed in the previous blog posting.  As you step through the content of the collection, use the APIs described below to retrieve the details of each asset for additional processing.


There are three basic methods to retrieve metadata for an asset:

  1. MBObject_GetMetadataValue – used to retrieve a single item of metadata from the metadata id
  2. MBObject_GetMetadataValues – used to retrieve several items of metadata from a list of metadata ids
  3. MBObject_GetMetadataValuesByGroup – used to retrieve all metadata in a certain group

Note: These calls can also apply to folders.  When used on a folder, metadata is read from the folder itself, not the individual assets in the folder.  


The first two calls simply take a metadata id, or a list of metadata ids, and return the values (if any) for those metadata items on the specified asset.  The third call requires a metadata group to be passed in.  This is a handy way to retrieve metadata from an asset without having to explicitly list the identifier for each item of metadata.  Just supply the identifier for a metadata group and the call will return all the metadata that’s assigned to the asset which is also in the group.  To get all the metadata assigned to an asset, just pass in a null as the group identifier.


In each of these calls the metadata is returned in a common object, a MBMetadataValue, as either a single item or an array of MBMetadataValue items.  Parsing the contents of the MBMetadataValue object requires a bit of coding in order to handle all the possible variations.  It’s important to note that a raw metadata value, such as a string, is never returned from these metadata calls.  Every returned value is always wrapped in a MBMetadataValue.


MBMetaDataValue contains: the name of the metadata item, its unique identifier, the actual metadata value(s) and several flags.  Amongst the more important flags is “HasMultipleValues”.  Use this to determine whether the value you are working with is an array type or a single value type.  Alternately, you may check the return from the getValues() method of MDMetaDataValue.  A null return value from getValues() indicates a single value type.


Since all values are returned in generic Objects, you will likely need to determine the type of each returned Object.  In Java, Introspection works well for this task. Alternately, you can determine the type of each metadata item from the MediaBin Server’s metadata catalog, by storing this information in a local hashmap for easy access.  Each MediaBin metadata type is returned as a native language type as determined in the table below. 


Note: This table is for the default JAXB/Axis 2.0 bindings; for Axis 1.0, Date and Date/Time types are returned as GregorianCalendar types.


MediaBin Metadata Type

Returned Object Type









Floating Point




String List


Value List






Putting all of this together, the example below (Figure 1) shows how to retrieve and parse the values of metadata assigned to an asset in MediaBin.


Figure 1 - Parsing a returned MBMetadataValue:




One final point: The thumbnail for an asset is best returned through use of the Webservice’s thumbnail streamer.  This will allow you to access the asset’s thumbnail using a URL.  The preview URL is returned in the PreviewURL property of the MBObject representing the asset.  The only twist here is you must ensure that the MediaBin Auth cookie (see HP MediaBin APIs: Part 1 - Getting Started blog post) is appended to the HTTP request header, otherwise you’ll get an error indicating you are logged out (Figure 2 below).


Figure 2 - Extracting an asset's preview image:


figure 2.JPG


That’s it for today.  In my next post we will discuss the various techniques used to apply metadata to an asset which will allow you to supplement the out-of-the-box metadata with custom fields in an automated way.


To download a copy of the source code referenced in this posting, click on the attachments below.




Read more on HP MediaBin APIs:

Digital Marketing: Leveraging the HP MediaBin APIs: Part 1 - Getting Started
Digital Marketing: Leveraging the HP MediaBin APIs: Part 2 – API Overview
Digital Marketing: Leveraging the HP MediaBin APIs: Part 3 – Searching

Leave a Comment

We encourage you to share your comments on this post. Comments are moderated and will be reviewed
and posted as promptly as possible during regular business hours

To ensure your comment is published, be sure to follow the Community Guidelines.

Be sure to enter a unique name. You can't reuse a name that's already in use.
Be sure to enter a unique email address. You can't reuse an email address that's already in use.
Type the characters you see in the picture above.Type the words you hear.
Showing results for 
Search instead for 
Do you mean 
About the Author
David Roy has over 27 years of experience in Software Engineering, with expertise in the areas of Digital Asset Management, Image Science an...

Follow Us
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.