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

Mark Carlson -- webMethods Ezine Columnist

Invoking EJBs in JBoss 3 using webMethods 6



By Mark Carlson

 


How to Install and Configure the webMethods EJB Adapter v1.2

If you don't have the file WmEJBAdapter_en_US.exe from the webMethods Advantage web site, find it. You may need to ask your company's designated webMethods contact for help with accessing the webMethods Software Download Center.

If you have the file, double-click it to launch the installation.

Follow the installation process and when prompted, choose to install the Adapter Development Kit (ADK) v1.5. The installer will also prompt you to install EJB examples. This article will not use the examples, but you can install them for digging deeper at a later date.

After the installation exits, copy the following JARs from the JBoss \client directory to the webMethods JAR directory:

  • jboss-client.jar
  • jboss-common-client.jar
  • jboss-j2ee.jar
  • jboss-net-client.jar
  • jbosssx-client.jar
  • jnet.jar
  • jnp-client.jar
  • jsse.jar
  • jlog4j.jar
Note: For JBoss versions other than 3.04, some of these JAR files may be found directories other than \client. Use your system's "Find..." feature if you have trouble locating them.

Next, use WinZip to open the webMethods file "jnet.jar" and delete the following files:

  • sun_micr.rsa
  • sun_micr.sf files

Restart your webMethod server, launch the Adminstrator GUI (http://serverhost:serverport/) and confirm the EJB adapter's installation. If you see the "Enterprise Java Beans" in the Adapters menu, consider it a success.

Select the link to launch the EJB Administration Main Menu.

To create a new alias, choose "Alias Settings" and then select the "Add Alias" button. Enter the following values:

  • Alias name: JBoss3
  • Description: JBoss3.04 Test Server
  • Initial Context Factory: org.jnp.interfaces.NamingContextFactory
  • Provider URL: jnp://localhost:1099 (change localhost to the IP Address or hostname for your JBoss server)
  • JNDI Server Type: JBoss
  • Leave all other fields blank

The Alias Settings page should resemble the following:

Alias settings page for creating an alias to the JBoss 3.04 test server from webMethods 6

Save your Alias Setting and confirm its operation by clicking the button in the "Test" column. If your alias is working properly, you will see the following:

Results of a successful test of the new JBoss3 alias from webMethods 6


Using the Server Browser to locate the EJBs

Click the Server Browser link and select the appropriate alias from the Server Alias drop-down list. Leave the "JNDI Lookup Name" field blank and click "Continue".

From the list of deployed EJBs, click the EJB that you want to browse. The server will return a Web page showing the selected EJB's details including its JNDI Lookup Name, Home Bean Name and Remote Bean Name. Note that the WmUsersEJB contains these five public methods:

  • addInts()
  • strConcat()
  • farenheitToCelcius()
  • celciusToFarenheit()
  • calculateCompoundInterest()

Public methods for the wMUsers EJB


Generating Flow from the Browser

Using the webMethods Developer, create a new package and add one sub-folder to it. Name both the package and the folder "JBossEJB".

Next, using the Adminstrator's EJB Menu, click "Service Generation" and then select the JBoss Server alias built earlier. Set the following parameters:

  • Package: JBossEJB
  • Folder: JBossEJB
  • Service Name: invokeAddInts
  • JNDI Lookup Name: wmusers/WmUsers

Then, select the create method for your EJB. This is the method that the IS server will invoke to instantiate your EJB.

Creation methods in the wMUsers EJB

After selecting a create method, build the Flow's order of execution for one or more public methods available in the EJB. In this example, we choose the addInts() method. Note that the Public Methods page lists each public method, its return type, and the number and type of its input parameters. Select "Continue".

EJB Service Generation Public Methods Selection Page

To confirm your settings, click "Generate".

EJB adapter service generation confirmation page

Returning to webMethods Developer, select "Refresh" to view the generated invokeAddInts service.

webMethods Developer screenshot showing the generated invokeAddInts Flow Service


Testing the Flow service

To test the Flow, create a new Flow in the JBossEJB package called JBossEJB:testAddInts with the following parameters:

  • Input variables: num1 (String), num2 (String)
  • Output variables: result (Object)
  • For users of webMethods 6 only, right-click the output variable result and select "Properties". Select the "Constraints" tab and set the variable's content type to "java.lang.Integer".

Add an invoke step to the Flow and select JBossEJB:invokeAddInts. Map num1 and num2 to the service's input variables.

Next, map the invokeAddInts output AddIntsReturnValMethod0 to the output variable result.

Save and run your flow service.

testAddInts flow service showing mapping of input variables to the invokeAddInts service


Exposing EJB methods as Enterprise Web services

Because all webMethods Flow and Java services are inherently available as Enterprise Web services, there is nothing to much to do here.

To confirm this idea, use the WmEWS package's Web services browser or use the Web Services Tools "adapter" that ships with webMethods 6 and navigate to JBossEJB:testAddInts.

Click "Test" to run the Flow as a Web service and browse the generated SOAP request and response documents or, if you’re a glutton for punishment, peruse the generated WSDL file.

You can also use an external SOAP client such as Apache AXIS or the test client shipped with the WmEWS bonus pack to invoke one of the EJB's public methods.


Resources



<<Prev  1  [2]  

Go Deeper on the Subject: The wMUsers Discussion Forums


Mark Carlson is the president and principal solutions architect of Conneva, Inc. which specializes in the design and development of webMethods-based integration architectures. Mark has over 18 years of experience in the IT industry and has worked with webMethods products for the past 3 years. Mark and his family live in Evergreen, Colorado at 8,000 feet above sea level.

Mark 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.