WSO2 Mashup Server

De Wikipedia, la enciclopedia libre
WSO2 Mashup Server
Información general
Tipo de programa Servidor de aplicaciones
Desarrollador WSO2 y la comunidad
Lanzamiento inicial 28 de enero de 2008
Discontinuación 8 de diciembre de 2012
Licencia licencia Apache 2.0
Idiomas inglés
Información técnica
Programado en Java
Plataformas admitidas Java
Versiones
Última versión estable 2.0.2 ( 13 de mayo de 2010 (13 años, 11 meses y 23 días))
Enlaces

El WSO2 Mashup Server (Servidor de Mashups de WSO2) es una plataforma de mashup de código abierto que aloja mashups basados en JavaScript. Está basado en Axis2 Apache y otros proyectos de código abierto y proporciona a los autores de JavaScript la capacidad de consumir, componer y emitir servicios web, feeds RSS, páginas web scraped, correo electrónico y mensajes instantáneos. El código fuente está disponible bajo la licencia abierta licencia Apache. Proporciona una plataforma de tiempo de ejecución para el desarrollo e implementación de mashups. Puede descargarse e instalarse localmente o dentro de una organización.

El servidor de Mashup WSO2 es centrado en servicios web en tanto que cada mashup expone un nuevo servicio web, que puede ser consumido por otros mashups, clientes de servicios web o páginas web de estilo AJAX. La creación de aplicaciones seguras de servicios web las convierte en una tecnología atractiva dentro de las organizaciones que implementan una arquitectura orientada a servicios (service-oriented architecture, SOA) y de mashup de negocios.

Hasta la fecha, es la única plataforma de composición de código abierto disponible para los desarrolladores de mashups.

JavaScript como un lenguaje de composición de mashup[editar]

Los Mashups se componen utilizando JavaScript del lado del servidor en el servidor de Mashup WSO2. Un conjunto de extensiones del lenguaje que junto con E4X proporciona funciones específicas de dominio, como;

  • Llamar a otros servicios web SOAP/REST,
  • Feeds RSS/Atom feed de lectura y escritura,
  • Web scraping,
  • Publicación basada en APP,
  • Programación de tareas periódicas,
  • Correo electrónico y
  • IM

Un Hola mundo[editar]

   function hello() {
       return "Hello World";
   }

Llamada a un servidor web SOAP[editar]

   function invokeGetVersionService(){
       var version = new WSRequest();

       var options = new Array();
       options.useSOAP = 1.2;
       options.useWSA = 1.0;
       options.action = "http://services.mashup.wso2.org/version/ServiceInterface/getVersionRequest";

       var payload = null;
       var result;

       try {
           version.open(options,"http://localhost:7762/services/system/version", false);
           version.send(payload);
           result = version.responseE4X;
       } catch (e) {
           system.log(e.toString(),"error");
           return e.toString();
       }
       return result;
   }

Trabajar con feeds[editar]

   // Creating an RSS 2.0 feed and writing it to file.
  function createRssFeed(){

   // Creating the Feed
   var feed = new Feed();
   feed.feedType = "rss_2.0";
   feed.title = "This is a test Feed";
   feed.description = "This feed demonstrates the use of Feed host object to create an RSS 2.0 feed.";
   feed.link = "http://mooshup.com/rss20.xml";

   // Creating Entries in the Feed
   var entry = new Entry();
   entry.title = "This is a test entry.";
   entry.description = "This is a sample entry demonstrating the use of the Entry host object.";
   feed.insertEntry(entry);

   var entry2 = new Entry();
   entry2.title = "This is another test entry.";
   entry2.description = "This is a sample entry demonstrating the use of the Entry host object.";

   // Adding a Media Module to the entry
   var mediaModule = new
   MediaModule("http://www.earthshots.org/photos/387.jpg");
   mediaModule.copyright = "2007 Tad Bowman";
   mediaModule.type = "image/jpeg";
   mediaModule.thumbnail = "http://web.archive.org/web/http://www.earthshots.org/photos/387.thumb.jpg";
   entry2.addMediaModule(mediaModule);

   feed.insertEntry(entry2);

   // Writing the newly created Feed to a File
   var result = feed.writeTo("test-created-rss-feed.xml");

   return result;
 }

Raspado Web (Web scraping)[editar]

 function webScrape(){
   var config = <config>
                   <var-def name='response'>
                       <html-to-xml>
                           <http method='get' url='http://ww2.wso2.org/~builder/'/>
                       </html-to-xml>
                   </var-def>
                </config>;

   var scraper = new Scraper(config);
   result = scraper.response;

   return result;
 }

La sintaxis es idéntica a otra herramienta de raspado web (web scraping) de código abierto llamada web harvest.

Trabajando con APP[editar]

 function persistAuthenticatedAppFeed(){
   // Creating an instance of APPClient
   var client = new APPClient();

   // Creating an instance of AtomFeed
   var feed = new AtomFeed();

   // Setting login credentials for the client
   client.credentials={username:"you@email.com",password:"xxx",service:"blogger",authtype:"google"};

   // Retrieving and online feed
   feed = client.getFeed("http://web.archive.org/web/http://blog.mooshup.com/feeds/posts/default");

   // Getting an array of individual entries from the feed
   var entries = new Array();
   entries = feed.getEntries();

   // Writing the retrieved feed to a file
   feed.writeTo("my-file-name.xml");
 }

Programación de tareas periódicas[editar]

 // Scheduling a function to be executed every 2 seconds
 var uuid = system.setInterval('myJavaScriptFunction("parameterValue")', 2000);

 // Stopping the above scheduled task
 system.clearInterval(uuid);

Envío de correo electrónico (mensaje de correo-e)[editar]

  function sendEmail(){
    var email = new Email("host", "port", "username", "password");
    var file = new File("temp.txt");
    email.from = "test@wso2.com";
    email.to = "test@wso2.com"; // alternatively message.to can be an array of strings. Same goes for cc and bcc
    email.cc = "test@wso2.com";
    email.bcc = "test@wso2.com";
    email.subject = "WSO2 Mashup server 1.0 Released";
    email.addAttachement(file, "temp.txt"); // Optionally can add attachments, it has a variable number of arguments. each argument can be a File hostObject or a string representing a file.
                                            // In this case we are sending two attachments (this demonstrates sending attachments using either a File Host Object or a path to the file).
    email.text = "WSO2 Mashup server 1.0 was Released on 28th January 2008";
    email.send();
  }

Referencias[editar]

Véase también[editar]

Enlaces externos[editar]

Nota[editar]