2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Mule Web Service Consumerを使ってみた

Last updated at Posted at 2023-05-23

はじめに

こんにちは、皆さん。今日は、一緒にMulesoftの Web Service Consumerについて掘り下げてみましょう!

Web Service Consumerは、異なるプラットフォームや言語間でのシームレスな統合を実現し、SOAPベースのWebサービスを簡単に呼び出すことが可能です。

本記事では、Web Service Consumerを使用して、SOAP APIを呼び出す時に、その設定方法、使用例について紹介していきます。

では、始めます。

用途

Anypoint Connector (Web Service Consumer Connector) は、SOAP APIを呼び出して、外部ソースからデータを取得できるコンポーネントです。

使い方

接続についての設定

SOAP APIへ接続するため、Mule側は主に五つのパラメータが必要です。

Web Service Consumer Config
image.png

名前 説明 必須
WSDL Location (WSDL の場所) String (文字列) WSDL ファイルの URL (リモートまたはローカル)。
Service (サービス) String (文字列) サービス名。
Port (ポート) String (文字列) ポート名。
Address (URL) String (文字列) Web サービスのアドレス。

Consume component
image.png

名前 説明 必須
Operation (操作) String (文字列) 呼び出す Web サービス操作の名前。

出典:Web Service Consumer Connector リファレンス - Mule 4

とは言え、そもそもWSDL、Service、Port、Address、Operationって、何?

WSDL、Service、Port、Address、Operation

WSDLとは?

SOAP APIのURL、パラメータのフォーマット情報などを記載されるドキュメントです。
Anypoint ExchangeにAPIのドキュメントと似ている感じ。

構造
image.png
参照:Oracleホームページ

いくつか要素があるですが、今回はMuleの設定に使う要素に、集中して紹介していきたいと思います。

definitions

WSDL文書のルート要素。

service

機能を定義する要素。

port

エンドポイントを定義する要素。binding要素と紐づく。

binding

プロトコルを定義する要素であり、複数Operation要素のまとめ。

operation

パラメータフォーマットを定義する要素。

address

URLを定義する要素。
Web Service Consumer Configでは、WSDLの定義には不一致な値を設定することは可能です。

service、port、binding、operation、addressの関係
image.png
出典:The Anatomy of WSDL

上記のように、Muleの「Web Service Consumer Config」と「Consume component」に適当な値に設定すると、SOAP APIへ接続はできているはずです。

Web Service Consumerの使用例

今回パブリックのsoap api、Number Conversion Serviceを呼び出して、
数字をアルファベットに変換する機能を実現してみます。

1.URLの末尾に?wsdlを追加することで、WSDLファイルを取得します。
image.png

2.右クリックして、「名前を付けて保存」をすると、wsdlファイルがダウンロードします。
image.png

3.フローを作成
image.png

4.Scheduler​ 設定
image.png

5.Set Variable​ 設定
image.png

6.Transform Message​ 設定
image.png

7.Consume​ 操作設定
image.png

8.Web Service Consumer Config 設定
image.png

9.Logger 設定
image.png

10.結果を確認、数字が変換されました。
image.png

Demoリンク:
number-conversion-service

最後までお読みいただきありがとうございます。気になる点があったらお知らせください。

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?