Hi Victor,
I assume, the full qualified type of the variable "resource" is com.sapportals.wcm.repository.IResource, isn't? This class represents a KM resource, for example an image or pdf file.
The IWDResource represents the resource of your Web Dynpro application, which you use in your user interface, for example an attachment or preview image etc.
Please see i.e. here: Getting an image from KM Documents to be used in Web Dynpro for an example of using these classes together
Regards,
Artem