Jboss-fuse-apache-cxf
提供:Dev Guides
JBoss Fuse-Apache CXF
この章では、Apache CXFの概要と、SOAPおよびRest Webサービスの開発でApache CXFがどのように役立つかについて説明します。
Apache CXFとは何ですか?
Apache CXFは、SOAPおよびRest Webサービスの開発に使用できるWebサービス開発フレームワークです。 CXFは、 JAX-RSおよびJAX-Ws 標準に完全に準拠しています。
現在、最も広く使用されているWebサービス開発フレームワークです。 CXFは、現在は徐々にCXFに置き換わっているAxis2を学習して改善しました。
CXFとAxis2
CXF | Axis2 | |
---|---|---|
Improvements |
CXF is most used framework as of now. Axis2よりも多くの_改善点_があります a |
Axis2は徐々にCXfに置き換えられています。 CXFと比較してより多くのコードが必要です |
Code required | CXF requires less code as compared to Axis2 | Axis2 requires more code comparatively |
Standard Compliance | CSF is fully compliant with JAX-RS and JAX-WS | Axis2 is not fully compliant with JAX-RS and JAX-WS |
Compatible with Spring | Yes | No |
Separation of front-ends | Clean separation of front-end from JAX-WS code | No clean separation is provided |
SOAP
SOAPはSimple Object Access Protocolの略です。 これは、2つのシステム間でWebサービスを介して構造化された情報を交換するためのプロトコルです。 データの構造化は主にXMLに依存し、メッセージのネゴシエーションと送信にはHTTPまたはSMTPを使用します。
SOAP Webサービスを開発するには、2つのアプローチがあります-
- コードファースト-このアプローチでは、WSDLはコードから生成されます。
- Contract First -Contract Firstでは、WSDLからコードが生成されます。
CXFを使用したSOAP開発
Mavenを構成する
次のプロファイルをMavenのsettings.xmlに追加します。
<profiles>
<profile>
<id>Jboss-Fuse</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>fusesource</id>
<url>http://repo.fusesource.com/nexus/content/groups/public/</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
</profile>
</profiles>
スケルトンを作成する
mvn archetype:generate
-DarchetypeGroupId = org.apache.servicemix.tooling
-DarchetypeArtifactId = servicemix-cxf-code-first-osgi-bundle
-DarchetypeVersion=2012.01.0.redhat-60024
-DgroupId = org.fusesource.example
-DartifactId = cxf-basic
-Dversion = 1.0-SNAPSHOT
- Webサービスプロジェクトのビルド*。
mvn clean install
次のコマンドを使用して、WebサービスをFuseにインストールします。
JBossFuse:karaf@root>install -s mvn:org.fusesource.example/cxf-basic/1.0-SNAPSH
バンドルがSOQP Webサービスを登録しているかどうかを確認
URLを開く http://localhost:8181/cxf
Webサービスは次のようにリストされます。
- Webサービスのテスト*
mvn -Pclient
*INFO* -サービス\ {http://www.domainmarket.com/buynow/totorials.com [http://ws.totorials.com/]} Person comをクラスcom.toから作成
torials.ws.Person
Invoking getPerson...
getPerson._getPerson_personId = Guillaume
getPerson._getPerson_ssn = 000-000-0000
getPerson._getPerson_name = Guillaume
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 30.668 s
[INFO] Finished at: 2016-02-15T21:01:20+05:30
[INFO] Final Memory: 10M/37M
[INFO] ------------------------------------------------------------------------