Join wMUsers | Blog at wMUsers | User Control Panel | Site Map | webMethods Jobs |For Employers

Daniel Mekonnen -- webMethods Ezine Columnist

Dressing up webMethods with Perl



By Daniel Mekonnen

 

Events are Hashes, Hashes are Events

Well, pretty close...at least that's the spirit. Line 21 of the previous example shows the new "toHash" method of event types. The "toHash" method will convert the broker event into a native Perl hash representation.

When converted to a hash, the event fields are copied as hash keys. The hash will sport an extra key, though, named "_name". "_name" contains the value that would be returned by a Perl API method call for getTypeName as shown on line 19 above.

Working in reverse, a new event can be created from an existing Perl hash:

    1   my $data ={
    2   _name  => "My::Demo",
    3   begin  => "Hello",
    4   middle => [
    5     { itemA => "alpha", itemB => "beta",  itemC => "gamma" },
    6     { itemA => "aleph", itemB => "bet",   itemC => "gimel" },
    7     { itemA => "alpha", itemB => "bravo", itemC => "golf"  }
    8   ],
    9   end    => "World"
    10  };
    11
    12  my $event = new Aw::Event ( $client, $data );
    13
    14  $client->publish ( $event );
    

In the true Perl spirit, there is no need to worry about pesky data types -- The Aw marshaling layer will properly convert and set each field's data type based upon the broker's stored event type definition.

Another demonstration script in the Aw package tests the hash-to-event conversion robustness.

The Perl script "Event of Doom" is a deeply-nested horror of struct arrays within struct arrays and so on. The struct arrays include every available event data type.

The script "eod.pl" illustrates the initialization of the complex "Event of Doom".

The script "eod-autotest.pl" goes one step further. It creates a test broker, a client group, an event definition (by applying hashes to typedefs) and the event. It then destroys the definitions and broker to complete the test.


Uses of the Perl Aw package

The Aw package was developed as an interface between ActiveWorks brokers and a very large infrastructure developed in Perl. The author has rapidly developed clients and adapters using the package and has not encountered limitations of any sort.

Some noteworthy projects involved using Perl scripts to create adapter clients in addition to embedding clients in server-side processed HTML documents. A mod_perl example that comes with the Aw package plays Tic-Tac-Toe in a Web browser against an adapter.

Imagine using the ActiveWorks broker "Monitor" to view Apache servers!

Perhaps more practically, an Enterprise broker can be turned into a SOAP server with Perl's SOAP-Lite package. The additional package, SOAP-Lite-ActiveWorks, provides all that you need to do just that.

The SOAP-Lite-ActiveWorks package also offers a gateway between an existing SOAP server and an Enterprise broker.


Limitations of the Aw package

The version of the Aw package at the time of this writing is 0.16.2.

The Aw package is compatible with any other Perl system. The package has not been tested on all possible combinations of the sundry versions of Perl, webMethods Enterprise Server, and operating systems versions and types.

The author has only deployed the package on the Solaris 2.6 platform and Perl versions 5.004_04 up to the present 5.8, and with ActiveWorks versions 3.0 and 4.0.2. Reliability with other versions is unknown.

A terse API reference comes with the Aw package. It is just enough to illustrate usage. Since the Perl APIs are modeled closely on the Java architecture, the webMethods Java Platform reference serves double duty as the Perl guide.

More than a few examples are provided with the package housed in the "bin" directory.

Finally, it must be noted that the Aw package was developed by neither Active Software nor the webMethods corporation. The package is not in anyway endorsed, supported or guaranteed by webMethods.

As with most every open source software, you are on your own in terms of installation and setup support.

That said, the author is available to offer limited assistance via email or in the webMethods User Community forums.



<<Prev  1  [2]  

Go Deeper on the Subject: The wMUsers Discussion Forums


Daniel Mekonnen has over 10 years of IT experience working with information exchange systems and has worked with webMethods since 1999. He enjoys the challenge of bringing systems together with enterprise technologies, data architecture design, and XML API design with standards like SOAP, WSDL and XML-RPC. Daniel works as a consultant in Northern Virginia.

Daniel can be reached via email at


Advertise at wMUsers






  Home | Join wMUsers | Discussion Forums | Knowledge Center | Jobs | Shareware | User Groups | Links |
Contact Us | Terms of Service | Privacy Policy

wMUsers is an independent organization and is not sponsored in any manner by Software AG.


© All Rights Reserved, 2001-2008.