You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ws.apache.org by Apache Wiki <wi...@apache.org> on 2005/04/04 07:09:36 UTC

[Ws Wiki] Update of "ja/axis/EJBinAxis" by ToshiyukiKimura

Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Ws Wiki" for change notification.

The following page has been changed by ToshiyukiKimura:
http://wiki.apache.org/ws/ja/axis/EJBinAxis

The comment on the change is:
Axis Wiki in Japanese

New page:
##language:ja

'''Axis 上で EJB を Webサービスとしてデプロイする方法''' by John Mammen (john_mammen@yahoo.com)

この手引きでは4つのクラスが出てきます。EJBに関連する3つのクラスと1つの詳細クラスです。

この bean を{{{Rates Bean}}}と呼ぶことにします。手短に説明すると、この bean の機能は、3桁の通貨コードが渡された時にその通貨の詳細レートを入手することです。

4つのクラスとは、リモート bean である{{{Rates.java}}}、実装 bean である {{{RatesBean.java}}}、ホーム bean である{{{RatesHome.java}}}、詳細レートを返す {{{RatesDetails.java}}}です。

以下は、{{{Weblogic}}}にデプロイするための{{{Rates bean}}}の xml デプロイメントディスクリプタと Java コードの抜粋です。これらは参考資料として使用することができます。

注意: 以下の抜粋は全て不完全です。必要な詳細のみが示されています。

'''{{{Rates.java}}}(EJB リモートクラスです)'''

{{{
......
public interface Rates extends EJBObject {

public RatesDetails getRateDetails(String currencyCode) throws
RemoteException,RateException;
...
}
}}}

'''{{{RateDetails.java}}}(リモート EJB 呼び出しで返されるクラスです)'''

{{{
...
public class RatesDetails implements Serializable{

private String isoCode;
private String vaildFrom;
private String vaildTo;
private double retailBuy;
private double retailMid;
private double retailSell;
private double wholesaleBuy;
private double wholesaleMid;
private double wholesaleSell;
private int rateType;
public RatesDetails() {
}
// setter と getter が定義されていますが、ここでは省略しています
}}}

'''ejb-jar.xml'''

{{{
<session>
<ejb-name>RatesBean</ejb-name>
<home>RatesHome</home>
<remote>Rates</remote>
<ejb-class>RatesBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
<resource-ref>
<description>Datasource for Rates DB</description>
<res-ref-name>jdbc/NewRatesDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</session>
}}}

'''weblogic-ejb-jar.xml'''

{{{
<weblogic-enterprise-bean>
<ejb-name>RatesBean</ejb-name>
<stateless-session-descriptor>
<pool>
<max-beans-in-free-pool>50</max-beans-in-free-pool>
<initial-beans-in-free-pool>5</initial-beans-in-free-pool>
</pool>
</stateless-session-descriptor>
<reference-descriptor>
<resource-description>
<res-ref-name>jdbc/NewRatesDB</res-ref-name>
<jndi-name>jdbc.RatePool</jndi-name>
</resource-description>
</reference-descriptor>
<jndi-name>jndi.Rates</jndi-name>
</weblogic-enterprise-bean>
}}}

上記のようなクラスがあり、コンテナへのデプロイが成功したと仮定します。これでWebサービスのデプロイを始めることができます。

1. まず、EJB が EJB コンテナに正しくデプロイできたか確認してください。

2. 次に J2EE アプリケーションサーバに Axis 1.0 をインストールして設定してください。

3. Axis インストールページで validate をクリックして、Axis のデプロイをテストしてください。

4. 以下に示すような rates.wsdd をメモ帳で作成してください。以下の例は上記の bean と対応しています。もし、パッケージに入れているのならば、クラス名にパッケージが含まれていることを確認してください。例えば、もし{{{RatesHome}}}が{{{com.mycompany}}}パッケージにあれば、ホームインターフェースの名前は {{{com.mycompany.RatesHome}}}になります。

{{{
<?xml version="1.0" encoding="UTF-8"?>
<deployment xmlns="http://xml.apache.org/axis/wsdd/"
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java"
xmlns:xsi="http:/www.w3.org/2000/10/XMLSchema-instance">
<service name="RateDetails" provider="java:EJB">
<parameter name="beanJndiName" value="jndi.Rates" />
<parameter name="homeInterfaceName" value="RatesHome" />
<parameter name="remoteInterfaceName" value="Rates" />
<parameter name="allowedMethods" value="getRateDetails" />
<parameter name="className" value="RatesBean" />
<parameter name="jndiURL" value="t3://localhost:7001" />
<parameter
name="jndiContextClass"
value="weblogic.jndi.WLInitialContextFactory" />
<typeMapping
xmlns:ns="http://soapinterop.org/xsd"
qname="ns:RatesDetails"
type="java:RatesDetails"
serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
/>
</service>
</deployment>
}}}

5. 次のコマンドで rates.wsdd をデプロイしてください。

{{{
java org.apache.axis.client.AdminClient -lhttp://localhost:7001/axis/services/ejbservice rates.wsdd
}}}

6. もし正しくデプロイできたのであれば、エラーメッセージを受け取ることはありません。もし何かしらのエラーがあれば、コンソールにそのエラーが表示されます。また、EJB コンテナのコンソールにもエラーがないか確かめてください。

7. ブラウザの url に{{{http://localhost:7001/axis/services/RateDetails?method=getRateDetails&value=USD}}}を入れてWebサービスをテストしてください。

もしデプロイが成功していたら、次のようなものを受け取ります。

'''Axis応答XML'''

{{{
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<geRateDetailsResponse
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<geRateDetailsReturn href="#id0"/>
</geRateDetailsResponse>
<multiRef id="id0" soapenc:root="0"
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xsi:type="ns1:RatesDetails"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:ns1="http://soapinterop.org/xsd">
<rateType xsi:type="xsd:int">0</rateType>
<wholesaleSell xsi:type="xsd:double">1.0</wholesaleSell>
<retailSell xsi:type="xsd:double">1.0</retailSell>
<retailMid xsi:type="xsd:double">1.0</retailMid>
<wholesaleMid xsi:type="xsd:double">1.0</wholesaleMid>
<validTo xsi:type="xsd:string" xsi:nil="true"/>
<validFrom xsi:type="xsd:string" xsi:nil="true"/>
<isoCode xsi:type="xsd:string" xsi:nil="true"/>
<retailBuy xsi:type="xsd:double">1.0</retailBuy>
<wholesaleBuy xsi:type="xsd:double">1.0</wholesaleBuy>
</multiRef>
</soapenv:Body>
</soapenv:Envelope>
}}}