•Axis2の本家のスタートガイドによるWebサービスの作り方
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
単語検索
|
最終更新
|
ヘルプ
]
開始行:
[[JAVAの記事一覧]]
*Axis2の本家のスタートガイドによるWebサービスの作り方(て...
*目次 [#w027dfbe]
#contents
*趣旨 [#p1d39041]
日本語のページみてもまともに最後まで動くドキュメントがな...
**本家 [#f62af722]
http://ws.apache.org/axis2/1_5_1/quickstartguide.html#dep...
**同じドキュメントをだいたい翻訳している方 [#cf2e1022]
結構はしょって訳しているかもしれないが、動作確認をおこな...
http://daipresents.com/weblog/fujihalab/archives/2008/04/...
**はじめに [#db009e6b]
サービスをスタートさせよう!。以下、簡単な例を示します。...
StockQuoteService という名前のサービスを用意しますが、こ...
では、以下の コード1をみてみましょう。
**コード1 StockQuoteServiceクラス [#j4c8e53f]
(訳者注:このコードはAXIS2を解凍したフォルダのquickstart...
package samples.quickstart.service.pojo;
import java.util.HashMap;
public class StockQuoteService {
private HashMap map = new HashMap();
public double getPrice(String symbol) {
Double price = (Double) map.get(symbol);
if(price != null){
return price.doubleValue();
}
return 42.00;
}
public void update(String symbol, double price) {
map.put(symbol, new Double(price));
}
}
これは、呼び出し可能なシンプルな2つのサービスです。1つ目...
手始めに、単純なJavaクラスをサービス化する方法をみていき...
**準備[#g4dae3a9]
Axis2を使って作業する前に、ちょっと準備必要です。
まず第一に、Axis2が動作する環境が整っている必要があるから...
+.Javaのダウンロードとインストールがすんでいること(最低限...
+.Axis2をダウンロードし、任意のディレクトリに解凍してある...
+.axis2.warを動作させるサーブレットエンジンのwebappsディ...
+.環境変数AXIS2_HOMEを上記のディレクトリに設定してあるこ...
だからこの手順を省略してはいけません! リナックスユーザは...
大抵は, さらにサービス用のWSDL fileが必要になります。 Axi...
**1.Javaクラスの作成とコンパイル [#i927b47f]
(訳者注:コンパイルしたクラスがないと下記のコマンドは動...
***(Windows) [#z76e9076]
%AXIS2_HOME%\bin\java2wsdl -cp . -cn samples.quickstart....
***(Linux) [#o265d424]
$AXIS2_HOME/bin/java2wsdl -cp . -cn samples.quickstart.s...
***(訳者注)eclipseを使った方法 [#md754762]
axis2を解凍するとサンプルがふくまれており、quickstartの...
これを使って.aarファイルや.wsdlファイルを生成することがで...
-メモ
org.apache.ws.java2wsdl.Java2WSDLTaskはaxis2-ant-plugin-1...
***生成されたStockQuoteService.wsdlファイル [#tbe65b7f]
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org...
<wsdl:types>
<xs:schema attributeFormDefault="qualified" eleme...
<xs:element name="update">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="s...
<xs:element minOccurs="0" name="p...
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="getPrice">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="s...
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="getPriceResponse">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="r...
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
</wsdl:types>
<wsdl:message name="getPriceRequest">
<wsdl:part name="parameters" element="ns:getPrice...
</wsdl:message>
<wsdl:message name="getPriceResponse">
<wsdl:part name="parameters" element="ns:getPrice...
</wsdl:message>
<wsdl:message name="updateRequest">
<wsdl:part name="parameters" element="ns:update"/>
</wsdl:message>
<wsdl:portType name="StockQuoteServicePortType">
<wsdl:operation name="getPrice">
<wsdl:input message="ns:getPriceRequest" wsaw...
<wsdl:output message="ns:getPriceResponse" ws...
</wsdl:operation>
<wsdl:operation name="update">
<wsdl:input message="ns:updateRequest" wsaw:A...
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="StockQuoteServiceSoap11Binding" t...
<soap:binding transport="http://schemas.xmlsoap.o...
<wsdl:operation name="getPrice">
<soap:operation soapAction="urn:getPrice" sty...
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="update">
<soap:operation soapAction="urn:update" style...
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="StockQuoteServiceSoap12Binding" t...
<soap12:binding transport="http://schemas.xmlsoap...
<wsdl:operation name="getPrice">
<soap12:operation soapAction="urn:getPrice" s...
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="update">
<soap12:operation soapAction="urn:update" sty...
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="StockQuoteServiceHttpBinding" typ...
<http:binding verb="POST"/>
<wsdl:operation name="getPrice">
<http:operation location="StockQuoteService/g...
<wsdl:input>
<mime:content type="text/xml" part="getPr...
</wsdl:input>
<wsdl:output>
<mime:content type="text/xml" part="getPr...
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="update">
<http:operation location="StockQuoteService/u...
<wsdl:input>
<mime:content type="text/xml" part="updat...
</wsdl:input>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="StockQuoteService">
<wsdl:port name="StockQuoteServiceHttpSoap11Endpo...
<soap:address location="http://localhost:8080...
</wsdl:port>
<wsdl:port name="StockQuoteServiceHttpSoap12Endpo...
<soap12:address location="http://localhost:80...
</wsdl:port>
<wsdl:port name="StockQuoteServiceHttpEndpoint" b...
<http:address location="http://localhost:8080...
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
**2.コマンドを使用したWSDLの生成: [#j6c42103]
いったんWSDLを生成していれば、お好みに合わせて修正するこ...
オリジナルな名前への変更したい時や不都合があった時にです。
たとえば、 AXIS2_HOME/samples/quickstartadb/resources/ME...
(訳者注:生成コマンドを実行したフォルダはクラス生成された...
にできたStockQuoteService.wsdl は, このガイドでずっと引き...
*Axis2のサービス[#n612434d]
構築前に助けになるのは、どのようなものが、できるのか理解...
Axis2はどんなサーバにでも配置できます。そして、下記のよう...
**Code Listing 2: The Directory Structure of axis2.war [#...
axis2-web
META-INF
WEB-INF
classes
conf
axis2.xml
lib
activation.jar
...
xmlSchema.jar
modules
modules.list
addressing.mar
...
soapmonitor.mar
services
services.list
aservice.aar
...
version.aar
web.xml
一番上からいくと、axis2-webはAXIS2の操作を構成するJSPが...
WEB-INF ディレクトリは contains the actual java classes a...
重要なファイルはaxis2.xmlです。どのようにどのようにメッセ...
ごらんのようにサービスは *.aar ファイルとして提供されます...
例として,このサービスの構成は次のようになります。
- StockQuoteService
- META-INF
- services.xml
- lib
- samples
- quickstart
- service
- pojo
- StockQuoteService.class
ここで、サービスの名前はStockQuoteServiceで, この名前はse...
最後に, META-INFディレクトリにはその他のAxis2がしっかり...
**コード3:サービス定義ファイル [#y5265167]
<service name="StockQuoteService" scope="application">
<description>
Stock Quote Sample Service
</description>
<messageReceivers>
<messageReceiver
mep="http://www.w3.org/2004/08/wsdl/in-only"
class="org.apache.axis2.rpc.receivers.RPCInOnlyMessag...
<messageReceiver
mep="http://www.w3.org/2004/08/wsdl/in-out"
class="org.apache.axis2.rpc.receivers.RPCMessageRecei...
</messageReceivers>
<parameter name="ServiceClass">
samples.quickstart.service.pojo.StockQuoteService
</parameter>
</service>
ここでサービスは定義されています。 messageReceiverタグに...
あなたがこのアプリケーションを取り込むつもりならば、META-...
あなたのサーブレットエンジンのディレクトリがthe webapps/a...
いま、あなたはわれわれが構築の準備がもう少しで完了しよう...
まず,Axis2の Standard Binaryをダウンロードし解凍してくだ...
環境変数のAXIS2_HOMEを先ほどダウンロードして解凍した展開...
さあ、いくつかクライアントやサービスの作成方法をみていき...
*サービスの作成 [#v30c395c]
この章では, 5通りのWebサービスの作り方示していきます。(...
+StockQuoteService と命名したPOJOなクラス。
+AXIOM形式、
+Axis2のデータをくっつけるフレームワークであるADB(Axis2...
+XML
+JiBX
**JavaのPOJOを用いた作成方法 [#lbe0b35e]
POJOsをつかってWebサービスを配備する手順を示します。
注意: ディレクトリ構成は AXIS2_HOME/samples/quickstart ...
***ディレクトリ構成 [#d256eb52]
- quickstart
- README.txt
- build.xml
- resources
- META-INF
- services.xml
- src
- samples
- quickstart
- service
- pojo
- StockQuoteService.java
注意: 次をタイプすることでディレクトリからWSDLを生成する...
ant generate.wsdl
しかしながら, StockQuoteService.wsdl の生成はANTのオプシ...
いま、コマンドのタイピングでAntからプロジェクトをビルドし...
- quickstart/build/classes
- META-INF
- services.xml
- samples
- quickstart
- service
- pojo
- StockQuoteService.class
もしあなたがサービスを配置したいのなら/ 膨大なディレクト...
**サービス一覧URL [#c97a78e9]
http://localhost:8080/axis2/services/listServices
または、下記のURLでWSDLを観察できます。
http://localhost:8080/axis2/services/StockQuoteService?w...
そしてスキーマのURL:
http://localhost:8080/axis2/services/StockQuoteService?xsd
いったんこれらのURLが動作していれば, 速やかにサービスをテ...
http://localhost:8080/axis2/services/StockQuoteService/g...
あなたは下記のレスポンスを得ることができたと思います。
<ns:getPriceResponse xmlns:ns="http://pojo.service.quick...
あなたはupdate methodを実行することができます。
http://localhost:8080/axis2/services/StockQuoteService/u...
そして最初にでてきたgetPriceのURLですが、あなたはupdated...
終了行:
[[JAVAの記事一覧]]
*Axis2の本家のスタートガイドによるWebサービスの作り方(て...
*目次 [#w027dfbe]
#contents
*趣旨 [#p1d39041]
日本語のページみてもまともに最後まで動くドキュメントがな...
**本家 [#f62af722]
http://ws.apache.org/axis2/1_5_1/quickstartguide.html#dep...
**同じドキュメントをだいたい翻訳している方 [#cf2e1022]
結構はしょって訳しているかもしれないが、動作確認をおこな...
http://daipresents.com/weblog/fujihalab/archives/2008/04/...
**はじめに [#db009e6b]
サービスをスタートさせよう!。以下、簡単な例を示します。...
StockQuoteService という名前のサービスを用意しますが、こ...
では、以下の コード1をみてみましょう。
**コード1 StockQuoteServiceクラス [#j4c8e53f]
(訳者注:このコードはAXIS2を解凍したフォルダのquickstart...
package samples.quickstart.service.pojo;
import java.util.HashMap;
public class StockQuoteService {
private HashMap map = new HashMap();
public double getPrice(String symbol) {
Double price = (Double) map.get(symbol);
if(price != null){
return price.doubleValue();
}
return 42.00;
}
public void update(String symbol, double price) {
map.put(symbol, new Double(price));
}
}
これは、呼び出し可能なシンプルな2つのサービスです。1つ目...
手始めに、単純なJavaクラスをサービス化する方法をみていき...
**準備[#g4dae3a9]
Axis2を使って作業する前に、ちょっと準備必要です。
まず第一に、Axis2が動作する環境が整っている必要があるから...
+.Javaのダウンロードとインストールがすんでいること(最低限...
+.Axis2をダウンロードし、任意のディレクトリに解凍してある...
+.axis2.warを動作させるサーブレットエンジンのwebappsディ...
+.環境変数AXIS2_HOMEを上記のディレクトリに設定してあるこ...
だからこの手順を省略してはいけません! リナックスユーザは...
大抵は, さらにサービス用のWSDL fileが必要になります。 Axi...
**1.Javaクラスの作成とコンパイル [#i927b47f]
(訳者注:コンパイルしたクラスがないと下記のコマンドは動...
***(Windows) [#z76e9076]
%AXIS2_HOME%\bin\java2wsdl -cp . -cn samples.quickstart....
***(Linux) [#o265d424]
$AXIS2_HOME/bin/java2wsdl -cp . -cn samples.quickstart.s...
***(訳者注)eclipseを使った方法 [#md754762]
axis2を解凍するとサンプルがふくまれており、quickstartの...
これを使って.aarファイルや.wsdlファイルを生成することがで...
-メモ
org.apache.ws.java2wsdl.Java2WSDLTaskはaxis2-ant-plugin-1...
***生成されたStockQuoteService.wsdlファイル [#tbe65b7f]
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org...
<wsdl:types>
<xs:schema attributeFormDefault="qualified" eleme...
<xs:element name="update">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="s...
<xs:element minOccurs="0" name="p...
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="getPrice">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="s...
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="getPriceResponse">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="r...
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
</wsdl:types>
<wsdl:message name="getPriceRequest">
<wsdl:part name="parameters" element="ns:getPrice...
</wsdl:message>
<wsdl:message name="getPriceResponse">
<wsdl:part name="parameters" element="ns:getPrice...
</wsdl:message>
<wsdl:message name="updateRequest">
<wsdl:part name="parameters" element="ns:update"/>
</wsdl:message>
<wsdl:portType name="StockQuoteServicePortType">
<wsdl:operation name="getPrice">
<wsdl:input message="ns:getPriceRequest" wsaw...
<wsdl:output message="ns:getPriceResponse" ws...
</wsdl:operation>
<wsdl:operation name="update">
<wsdl:input message="ns:updateRequest" wsaw:A...
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="StockQuoteServiceSoap11Binding" t...
<soap:binding transport="http://schemas.xmlsoap.o...
<wsdl:operation name="getPrice">
<soap:operation soapAction="urn:getPrice" sty...
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="update">
<soap:operation soapAction="urn:update" style...
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="StockQuoteServiceSoap12Binding" t...
<soap12:binding transport="http://schemas.xmlsoap...
<wsdl:operation name="getPrice">
<soap12:operation soapAction="urn:getPrice" s...
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="update">
<soap12:operation soapAction="urn:update" sty...
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="StockQuoteServiceHttpBinding" typ...
<http:binding verb="POST"/>
<wsdl:operation name="getPrice">
<http:operation location="StockQuoteService/g...
<wsdl:input>
<mime:content type="text/xml" part="getPr...
</wsdl:input>
<wsdl:output>
<mime:content type="text/xml" part="getPr...
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="update">
<http:operation location="StockQuoteService/u...
<wsdl:input>
<mime:content type="text/xml" part="updat...
</wsdl:input>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="StockQuoteService">
<wsdl:port name="StockQuoteServiceHttpSoap11Endpo...
<soap:address location="http://localhost:8080...
</wsdl:port>
<wsdl:port name="StockQuoteServiceHttpSoap12Endpo...
<soap12:address location="http://localhost:80...
</wsdl:port>
<wsdl:port name="StockQuoteServiceHttpEndpoint" b...
<http:address location="http://localhost:8080...
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
**2.コマンドを使用したWSDLの生成: [#j6c42103]
いったんWSDLを生成していれば、お好みに合わせて修正するこ...
オリジナルな名前への変更したい時や不都合があった時にです。
たとえば、 AXIS2_HOME/samples/quickstartadb/resources/ME...
(訳者注:生成コマンドを実行したフォルダはクラス生成された...
にできたStockQuoteService.wsdl は, このガイドでずっと引き...
*Axis2のサービス[#n612434d]
構築前に助けになるのは、どのようなものが、できるのか理解...
Axis2はどんなサーバにでも配置できます。そして、下記のよう...
**Code Listing 2: The Directory Structure of axis2.war [#...
axis2-web
META-INF
WEB-INF
classes
conf
axis2.xml
lib
activation.jar
...
xmlSchema.jar
modules
modules.list
addressing.mar
...
soapmonitor.mar
services
services.list
aservice.aar
...
version.aar
web.xml
一番上からいくと、axis2-webはAXIS2の操作を構成するJSPが...
WEB-INF ディレクトリは contains the actual java classes a...
重要なファイルはaxis2.xmlです。どのようにどのようにメッセ...
ごらんのようにサービスは *.aar ファイルとして提供されます...
例として,このサービスの構成は次のようになります。
- StockQuoteService
- META-INF
- services.xml
- lib
- samples
- quickstart
- service
- pojo
- StockQuoteService.class
ここで、サービスの名前はStockQuoteServiceで, この名前はse...
最後に, META-INFディレクトリにはその他のAxis2がしっかり...
**コード3:サービス定義ファイル [#y5265167]
<service name="StockQuoteService" scope="application">
<description>
Stock Quote Sample Service
</description>
<messageReceivers>
<messageReceiver
mep="http://www.w3.org/2004/08/wsdl/in-only"
class="org.apache.axis2.rpc.receivers.RPCInOnlyMessag...
<messageReceiver
mep="http://www.w3.org/2004/08/wsdl/in-out"
class="org.apache.axis2.rpc.receivers.RPCMessageRecei...
</messageReceivers>
<parameter name="ServiceClass">
samples.quickstart.service.pojo.StockQuoteService
</parameter>
</service>
ここでサービスは定義されています。 messageReceiverタグに...
あなたがこのアプリケーションを取り込むつもりならば、META-...
あなたのサーブレットエンジンのディレクトリがthe webapps/a...
いま、あなたはわれわれが構築の準備がもう少しで完了しよう...
まず,Axis2の Standard Binaryをダウンロードし解凍してくだ...
環境変数のAXIS2_HOMEを先ほどダウンロードして解凍した展開...
さあ、いくつかクライアントやサービスの作成方法をみていき...
*サービスの作成 [#v30c395c]
この章では, 5通りのWebサービスの作り方示していきます。(...
+StockQuoteService と命名したPOJOなクラス。
+AXIOM形式、
+Axis2のデータをくっつけるフレームワークであるADB(Axis2...
+XML
+JiBX
**JavaのPOJOを用いた作成方法 [#lbe0b35e]
POJOsをつかってWebサービスを配備する手順を示します。
注意: ディレクトリ構成は AXIS2_HOME/samples/quickstart ...
***ディレクトリ構成 [#d256eb52]
- quickstart
- README.txt
- build.xml
- resources
- META-INF
- services.xml
- src
- samples
- quickstart
- service
- pojo
- StockQuoteService.java
注意: 次をタイプすることでディレクトリからWSDLを生成する...
ant generate.wsdl
しかしながら, StockQuoteService.wsdl の生成はANTのオプシ...
いま、コマンドのタイピングでAntからプロジェクトをビルドし...
- quickstart/build/classes
- META-INF
- services.xml
- samples
- quickstart
- service
- pojo
- StockQuoteService.class
もしあなたがサービスを配置したいのなら/ 膨大なディレクト...
**サービス一覧URL [#c97a78e9]
http://localhost:8080/axis2/services/listServices
または、下記のURLでWSDLを観察できます。
http://localhost:8080/axis2/services/StockQuoteService?w...
そしてスキーマのURL:
http://localhost:8080/axis2/services/StockQuoteService?xsd
いったんこれらのURLが動作していれば, 速やかにサービスをテ...
http://localhost:8080/axis2/services/StockQuoteService/g...
あなたは下記のレスポンスを得ることができたと思います。
<ns:getPriceResponse xmlns:ns="http://pojo.service.quick...
あなたはupdate methodを実行することができます。
http://localhost:8080/axis2/services/StockQuoteService/u...
そして最初にでてきたgetPriceのURLですが、あなたはupdated...
ページ名: