20.3. Usage


20.3.1. 全般

camel-quarkus-cxf-soap は、CXF Extensions for Quarkus プロジェクト (quarkus-cxf) のエクステンションを使用します。つまり、quarkus-cxf は、サポート対象のユースケースおよび WS 仕様のセットを提供します。

重要

サポート対象のユースケースおよび WS 仕様の詳細は、Quarkus CXF Reference を参照してください。

20.3.2. 依存関係の管理

Camel Extensions for Quarkus は、CXF および quarkus-cxf バージョンを 管理 します。これらのプロジェクトと互換性があるバージョンを選択する必要はありません。

20.3.3. クライアント

camel-quarkus-cxf-soap (追加の依存関係は不要) を使用すると、CXF クライアントを Camel ルートでプロデューサーとして使用できます。

import org.apache.camel.builder.RouteBuilder;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.context.SessionScoped;
import javax.enterprise.inject.Produces;
import javax.inject.Named;

@ApplicationScoped
public class CxfSoapClientRoutes extends RouteBuilder {

    @Override
    public void configure() {

        /* You can either configure the client inline */
        from("direct:cxfUriParamsClient")
                .to("cxf://http://localhost:8082/calculator-ws?wsdlURL=wsdl/CalculatorService.wsdl&dataFormat=POJO&serviceClass=org.foo.CalculatorService");

        /* Or you can use a named bean produced below by beanClient() method */
        from("direct:cxfBeanClient")
                .to("cxf:bean:beanClient?dataFormat=POJO");

    }

    @Produces
    @SessionScoped
    @Named
    CxfEndpoint beanClient() {
        final CxfEndpoint result = new CxfEndpoint();
        result.setServiceClass(CalculatorService.class);
        result.setAddress("http://localhost:8082/calculator-ws");
        result.setWsdlURL("wsdl/CalculatorService.wsdl"); // a resource in the class path
        return result;
    }
}
Copy to Clipboard Toggle word wrap

CalculatorService は以下のようになります。

import javax.jws.WebMethod;
import javax.jws.WebService;

@WebService(targetNamespace = CalculatorService.TARGET_NS)
public interface CalculatorService {

    public static final String TARGET_NS = "http://acme.org/wscalculator/Calculator";

    @WebMethod
    public int add(int intA, int intB);

    @WebMethod
    public int subtract(int intA, int intB);

    @WebMethod
    public int divide(int intA, int intB);

    @WebMethod
    public int multiply(int intA, int intB);
}
Copy to Clipboard Toggle word wrap
注記

JAX-WS アノテーションが必要です。Simple CXF フロントエンドはサポートされていません。ネイティブモードで適切に機能させるには、複雑なパラメータータイプに JAXB アノテーションが必要です。

ヒント

このサービスエンドポイントインターフェイスを実装する quay.io/l2x6/calculator-ws:1.2 コンテナーに対して、このクライアントアプリケーションをテストできます。

$ docker run -p 8082:8080 quay.io/l2x6/calculator-ws:1.2
Copy to Clipboard Toggle word wrap
注記

quarkus-cxf は、@io.quarkiverse.cxf.annotation.CXFClient アノテーションを使用する SOAP クライアントの挿入 をサポートします。詳細は、quarkus-cxf ユーザーガイドの SOAP クライアント の章を参照してください。

20.3.4. Server

camel-quarkus-cxf-soap を使用すると、SOAP エンドポイントを Camel ルートのコンシューマーとして公開できます。このユースケースには、追加の依存関係は必要ありません。

import org.apache.camel.builder.RouteBuilder;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.Produces;
import javax.inject.Named;

@ApplicationScoped
public class CxfSoapRoutes extends RouteBuilder {

    @Override
    public void configure() {
        /* A CXF Service configured through a CDI bean */
        from("cxf:bean:helloBeanEndpoint")
                .setBody().simple("Hello ${body} from CXF service");

        /* A CXF Service configured through Camel URI parameters */
        from("cxf:///hello-inline?wsdlURL=wsdl/HelloService.wsdl&serviceClass=org.foo.HelloService")
                        .setBody().simple("Hello ${body} from CXF service");
    }

    @Produces
    @ApplicationScoped
    @Named
    CxfEndpoint helloBeanEndpoint() {
        final CxfEndpoint result = new CxfEndpoint();
        result.setServiceClass(HelloService.class);
        result.setAddress("/hello-bean");
        result.setWsdlURL("wsdl/HelloService.wsdl");
        return result;
    }
}
Copy to Clipboard Toggle word wrap

これら 2 つのサービスのパスは、application.properties などに設定できる quarkus.cxf.path 設定プロパティー の値によって異なります。

application.properties

quarkus.cxf.path = /soap-services
Copy to Clipboard Toggle word wrap

この設定を適用すると、http://localhost:8080/soap-services/hello-bean および http://localhost:8080/soap-services/hello-inline の 2 つのサービスにそれぞれアクセスできます。

上記の URL に ?wsdl を追加することで、WSDL にアクセスできます。

重要

他のエクステンションが HTTP エンドポイントを公開しないと 100% 確信できない限り、アプリケーションで quarkus.cxf.path = / を使用しないでください。

CEQ 2.13.3 以降では、quarkus.cxf.path のデフォルト値は / です。デフォルト値は、他のエクステンションが HTTP エンドポイントを公開しないようにします。

これは RESTEasy、Vert.x、SmallRy Health などに影響します。これらを使用する場合は、quarkus.cxf.path を、/services などの特定のパスに設定する必要があります。これは、Camel Extensions for Quarkus 3.0.0 / quarkus-cxf 2.0.0 で始まるデフォルトです。

注記

quarkus-cxf は、SOAP エンドポイントを公開する代替方法をサポートします。詳細は、quarkus-cxf ユーザーガイドの SOAP Services の章を参照してください。

20.3.5. 要求および応答のロギング

org.apache.cxf.ext.logging.LoggingFeature を使用して、クライアントとサーバーの SOAP メッセージの詳細ロギングを有効にできます。

import org.apache.camel.builder.RouteBuilder;
import org.apache.cxf.ext.logging.LoggingFeature;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.context.SessionScoped;
import javax.enterprise.inject.Produces;
import javax.inject.Named;

@ApplicationScoped
public class MyBeans {

    @Produces
    @ApplicationScoped
    @Named("prettyLoggingFeature")
    public LoggingFeature prettyLoggingFeature() {
        final LoggingFeature result = new LoggingFeature();
        result.setPrettyLogging(true);
        return result;
    }

    @Inject
    @Named("prettyLoggingFeature")
    LoggingFeature prettyLoggingFeature;

    @Produces
    @SessionScoped
    @Named
    CxfEndpoint cxfBeanClient() {
        final CxfEndpoint result = new CxfEndpoint();
        result.setServiceClass(CalculatorService.class);
        result.setAddress("https://acme.org/calculator");
        result.setWsdlURL("wsdl/CalculatorService.wsdl");
        result.getFeatures().add(prettyLoggingFeature);
        return result;
    }

    @Produces
    @ApplicationScoped
    @Named
    CxfEndpoint helloBeanEndpoint() {
        final CxfEndpoint result = new CxfEndpoint();
        result.setServiceClass(HelloService.class);
        result.setAddress("/hello-bean");
        result.setWsdlURL("wsdl/HelloService.wsdl");
        result.getFeatures().add(prettyLoggingFeature);
        return result;
    }
}
Copy to Clipboard Toggle word wrap
注記

io.quarkiverse.cxf:quarkus-cxf-rt-features-logging は、camel-quarkus-cxf-soap 依存関係として org.apache.cxf.ext.logging.LoggingFeature のサポートを提供します。

アプリケーションに明示的に追加する必要はありません。

20.3.6. WS 仕様

サポートされる WS 仕様の範囲は、Quarkus CXF プロジェクトによって提供されます。

重要

サポート対象のユースケースおよび WS 仕様の詳細は、Quarkus CXF Reference を参照してください。

アプリケーションで他の WS 仕様が必要な場合は、それに対応する Quarkus CXF 依存関係を追加する必要があります。

Camel Extensions for Quarkus では、サポートレベル Stable でリストされているすべてのエクステンションをサポートします。

ヒント

さまざまな WS 仕様を実装するアプリケーションの実行可能な例として、統合テストを使用できます。

20.3.7. ツール

quarkus-cxf は、以下の 2 つの CXF ツールをラップします。

重要

wsdl2Java が適切に機能するには、アプリケーションは io.quarkiverse.cxf:quarkus-cxf に直接依存する必要があります。

ヒント

wsdlvalidator はサポート対象外ですが、application.properties で以下の設定を指定し、wsdl2Java を使用して WSDL を検証できます。

application.properties

quarkus.cxf.codegen.wsdl2java.additional-params = -validate
Copy to Clipboard Toggle word wrap

トップに戻る
Red Hat logoGithubredditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

Red Hat ドキュメントについて

Red Hat をお使いのお客様が、信頼できるコンテンツが含まれている製品やサービスを活用することで、イノベーションを行い、目標を達成できるようにします。 最新の更新を見る.

多様性を受け入れるオープンソースの強化

Red Hat では、コード、ドキュメント、Web プロパティーにおける配慮に欠ける用語の置き換えに取り組んでいます。このような変更は、段階的に実施される予定です。詳細情報: Red Hat ブログ.

会社概要

Red Hat は、企業がコアとなるデータセンターからネットワークエッジに至るまで、各種プラットフォームや環境全体で作業を簡素化できるように、強化されたソリューションを提供しています。

Theme

© 2025 Red Hat