推奨されるマイグレーション手法は、 SCA コンポーネントとしてステートレス・セッション EJB を呼び出すことができるようにする、 ステートレス・セッション・バインディング・タイプの WebSphere® Integration Developer Import を使用することです。 マイグレーション時に、SCA Java™ インターフェースのスタイルと既存の EJB インターフェースのスタイルの間で変換されるように、 カスタムの Java コードが作成されている必要があります。
<types> <schema xmlns="http://www.w3.org/2001/XMLSchema" attributeFormDefault="qualified" elementFormDefault="unqualified" targetNamespace="http://migr.practice.ibm.com/" xmlns:xsd1="http://migr.practice.ibm.com/"> <complexType name="StockInfo"> <all> <element name="index" type="int"/> <element name="price" type="double"/> <element name="symbol" nillable="true" type="string"/> </all> </complexType> </schema> </types> <message name="getStockInfoRequest"> <part name="symbol" type="xsd:string"/> </message> <message name="getStockInfoResponse"> <part name="result" type="xsd1:StockInfo"/> </message> <operation name="getStockInfo" parameterOrder="symbol"> <input message="tns:getStockInfoRequest" name="getStockInfoRequest"/> <output message="tns:getStockInfoResponse" name="getStockInfoResponse"/> </operation>以下のコードは、WSDL に対応する WebSphere Studio Application Developer Integration Edition 5.1 Java メソッドを示しています。
public StockInfo getStockInfo(String symbol) { return new StockInfo(); } public void setStockPrice(String symbol, float newPrice) { // set some things }以下のコードは、同じ WSDL 用の WebSphere Integration Developer 6.0 Java メソッドを示しています。
public DataObject getStockInfo(String aString) { //TODO Needs to be implemented. return null; } public void setStockPrice(String symbol, Float newPrice) { //TODO Needs to be implemented. }生成された Java 実装クラスの中の「//TODO」タグで示されている部分には、 最終的に実際のコードを入力する必要があります。 まず最初に、この Java コンポーネントから実際の EJB への参照を作成して、 これが SCA プログラミング・モデルに従って EJB にアクセスできるようにする必要があります。
private YourEJBInterface ejbService = null;
private BOFactory boFactory = (BOFactory) ServiceManager.INSTANCE.locateService(“com/ibm/websphere/bo /BOFactory”);
// Locate the EJB service this.ejbService = (YourEJBInterface) ServiceManager.INSTANCE.locateService("name-of-your-ejb-reference");
/** * Method generated to support the implementing WSDL port type named * "interface.MyBean". */ public BusObjImpl getStockInfo(String aString) { BusObjImpl boImpl = null; try { // invoke the EJB method StockInfo stockInfo = this.ejbService.getStockInfo(aString); // formulate the SCA data object to return. boImpl = (BusObjImpl) this.boFactory.createByClass(StockInfo.class); // manually convert all data from the EJB return type into the // SCA data object to return boImpl.setInt("index", stockInfo.getIndex()); boImpl.setString("symbol", stockInfo.getSymbol()); boImpl.setDouble("price", stockInfo.getPrice()); } catch (RemoteException e) { e.printStackTrace(); } return boImpl; } /** * Method generated to support the implementing WSDL port type named * "interface.MyBean". */ public void setStockPrice(String symbol, Float newPrice) { try { this.ejbService.setStockPrice(symbol, newPrice.floatValue()); } catch (RemoteException e) { e.printStackTrace(); } }