Skip to Content

Today, the EJB developers on NetWeaver need to do the development of EJB and create a Client for test it remotely.

With NetWeaver CE 7.2 a great tool is available, the EJB Explorer.

With EJB Explorer the methods of an EJB can be tested through the browser in similar way to WS Navigator.

The use EJB Explorer has some advantages like the eliminate the necessity of create a client just to test remotely and eliminate the necessity of update the Remote interface on client to reflect the new methods and so.

With this tool you can write your client just when you have finished the server development.

To this demonstration I’ll use the following objects:

Remote Interface</p><p><textarea cols=”80″ rows=”8″>package sdn.ejbexplorer.service;

import javax.ejb.Remote;

import sdn.ejbexplorer.model.SearchResponse;

import java.util.List;

import sdn.ejbexplorer.model.SearchRequest;

@Remote

public interface SDNServiceRemote {

     public List<SearchResponse> findProduct (SearchRequest searchRequest);

}</textarea></p><p>Local Interface</p><p>*<textarea cols=”80″ rows=”9″>package sdn.ejbexplorer.service;

import javax.ejb.Local;

import sdn.ejbexplorer.model.SearchResponse;

import java.util.List;

import sdn.ejbexplorer.model.SearchRequest;

@Local

public interface SDNServiceLocal {

     public List<SearchResponse> findProduct (SearchRequest searchRequest);

}</textarea></p><p>Bean Implementation</p><p>package sdn.ejbexplorer.service;

import java.util.ArrayList;

import java.util.List;

import javax.ejb.Stateless;

import sdn.ejbexplorer.model.SearchRequest;

import sdn.ejbexplorer.model.SearchResponse;

/**

  • Session Bean implementation class SDNServiceBean

*/

@Stateless

public class SDNServiceBean implements SDNServiceRemote, SDNServiceLocal {

     public List</p><p>Request Model</p><p>package sdn.ejbexplorer.model;import java.io.Serializable;public class SearchRequest implements Serializable { private static final long serialVersionUID = 1L;  private String description; private String status;  public String getDescription() {  return description; } public void setDescription(String description) {  this.description = description; } public String getStatus() {  return status; } public void setStatus(String status) {  this.status = status; }}

</p><p>Response Model</p><p>To find it just select the Remote Interface and see Lookup String, to example is: ejb:/appName=demo.sap.com/sdnejbexplorerapp, jarName=demo.sap.comsdnejbexplorer~ejb.jar, beanName=SDNServiceBean, interfaceName=sdn.ejbexplorer.service.SDNServiceRemote

!https://weblogs.sdn.sap.com/weblogs/images/251907834/ejb-explorer-6.png|height=149|alt=image|width=700|src=https://weblogs.sdn.sap.com/weblogs/images/251907834/ejb-explorer-6.png|border=0!</body>

To report this post you need to login first.

8 Comments

You must be Logged on to comment or reply to a post.

  1. rafael oshiro
    It’s such a great improvement in NW 7.2 and surely it will help many JEE developers to diminish their time creating and updating EJB clients.

    Thanks for sharing that.

    (0) 
  2. Siarhei Pisarenka
    Actually having such a tool will make EJB developer’s life much easier in many cases.

    However I see that the tool is not a panacea for large projects. Imagine the situation if I have more then 20 EJB services in a project. With the tool I have to spend about half a day or more if I like to test all the services. Then next release is coming and I again shall spend my time clicking all the 20 services, clicking and clicking again in order to prepare the set of input arguments for each of the service. Even if a service is not changed between the two releases I shall test it and prepare the same input arguments as before.

    Testing activities with the tool is manual (not automated) and very boring actually. There is no the catalog for reusable test data.

    In the same time Unit tests allow to automate the testing activities – to execute the same set of tests when new release is coming, to store easily test data (input arguments) in XML files, for example, or even hardcode them in the Java test classes.

    Unit tests allow to automate all the process, but the tool does not 🙁

    Best Regards,
    Siarhei

    (0) 
    1. Isaías Cristiano Barroso Post author
      Hi Siarhei,

      I think it isn’t a tool to replace the tools used to a complete application life cycle (unit tests, continuous integration and so)

      Another think is that many companies don’t have a Development process mature where Unit Tests, Continuous Integration are fully adopted. So a tool like that can help on Development Phase.

      Thanks by your comment, tests and continuous integration are good subjects for Blog Posts about NetWeaver development.

      Best regards

      (0) 

Leave a Reply