WEB开发网
开发学院软件开发Java 利用 WebSphere Process Server 7 轻松定做属于自... 阅读

利用 WebSphere Process Server 7 轻松定做属于自己的 EJB service

 2010-05-21 00:00:00 来源:WEB开发网   
核心提示: 图 8. 生成 Dynamic Web Project按照下图所示配置该动态 Web Project:图 9. 配置 Dynamic Web Project在生成的 Java Resources/src 文件夹下,新建一个 Java 类 “EJBExportInvoker&rdquo

图 8. 生成 Dynamic Web Project
利用 WebSphere Process Server 7 轻松定做属于自己的 EJB service

按照下图所示配置该动态 Web Project:

图 9. 配置 Dynamic Web Project
利用 WebSphere Process Server 7 轻松定做属于自己的 EJB service

在生成的 Java Resources/src 文件夹下,新建一个 Java 类 “EJBExportInvoker”, 并写入如下代码以调用前面所创建的 EJB3.0 Remote Export Binding:

清单 2. EJB Export Invoker Class 的代码片断

try{ 
 String jndiName = " 
li1627uc14075ejb3remotewsdltwowayexport.ejb3remotetwoway.binding.EJB3RemoteTwoWayRemote 
"; 
 Context initialContext = newInitialContext(); 
  java.lang.Object ejbBusIntf = initialContext.lookup(jndiName); 
 System.out.println(ejbBusIntf); 
 System.out.println(ejbBusIntf.getClass()); 
 System.out.println(ejbBusIntf.getClass().getName()); 
 EJB3RemoteTwoWay busI = (EJB3RemoteTwoWay) javax.rmi.PortableRemoteObject 
 .narrow(ejbBusIntf, EJB3RemoteTwoWay.class); 
 System.out.println(busI); 
 System.out.println(busI.getClass()); 
 System.out.println(busI.getClass().getName()); 
 
 Customer customer = newCustomer(); 
 customer.setCustId("custId-" + input); 
 customer.setEmail("email-" + input); 
 
 Address address = newAddress(); 
 address.setAddressId("addressId-" + input); 
 address.setAddressType(newInteger(100)); 
  customer.setHomeAddress(address); 
  Customer response = busI.e3Remotetwoway(customer); 
 if(response != null) { 
 if(customer.getCustId().equals(response.getCustId()) 
  && customer.getEmail().equals(response.getEmail()) 
 && (response.getHomeAddress() != null&& (customer 
 .getHomeAddress().getAddressId().equals( 
    response.getHomeAddress().getAddressId()) && customer 
    .getHomeAddress().getAddressType().equals( 
   response.getHomeAddress().getAddressType())))) { 
 System.out.println("@@@@@@@@@@@Response success!"); 
 } else{ 
 System.out.println(response.getCustId()); 
 System.out.println(response.getEmail()); 
 System.out.println(response.getHomeAddress().getAddressId()); 
 System.out.println(response.getHomeAddress().getAddressType()); 
   } 
 } else{ 
 System.out.println("@@@@@@@@@@@@@@response is null!!!"); 
  } 
  
 System.out.println("===================>> end of client"); 
 } catch(NamingException e) { 
  e.printStackTrace(); 
 } catch(Exception e) { 
  e.printStackTrace(); 
  } 

上一页  1 2 3 4 5 6 7 8 9  下一页

Tags:利用 WebSphere Process

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接