---
schema_version: "1"
id: 036ed55244961425ca4cd74487ea465995526c4e8f250c45b905779aaf81fcc3
title: AS2 メッセージの受信と MDN の返送
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/as2-connector/6.8/as2-connector-example-receive-send.md
canonical_url: https://docs.mulesoft.com/jp/as2-connector/6.8/as2-connector-example-receive-send
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 2167977375fcf14758b7e04e0c08fa10811814aa39511f85e547d1d770552f1b
description: MuleSoft Documentation Site
release: "6.8"
latest: false
---
# AS2 メッセージの受信と MDN の返送

次の例は、Anypoint Connector for AS2 (AS2 Connector) を使用して、取引パートナーから AS2 メッセージを受信し、応答で MDN (Message Disposition Notification) をそのパートナーに送信する方法を示しています。

- [AS2 メッセージの受信](#receiving-messages)
    
    パートナーから AS2 メッセージを受信し、受信したメッセージごとに、メッセージペイロードを含むメッセージを Studio コンソールに記録します。
- [同期 AS2 MDN の送信](#synchronous-mdns)
    
    受信した各 AS2 メッセージへの応答で同期 AS2 MDN を送信します。
- [非同期 AS2 MDN の送信](#asynchronous-mdns)
    
    受信した各 AS2 メッセージへの応答で非同期 AS2 MDN を送信します。

## [](#receiving-messages)AS2 メッセージの受信

この例を作成するには、新しい Mule プロジェクトを作成し、​**As 2 Listener**​ ソースと ​**Logger**​ コンポーネントを設定する必要があります。

次のスクリーンショットは、この例の Anypoint Studio アプリケーションフローを示しています。

![AS2 メッセージの受信アプリケーションフロー](/mulesoft/current/ja-jp/as2-connector/6.8/_images/as2-connector-example-listener-flow.png)

### [](#メッセージを受信するフローを作成する)メッセージを受信するフローを作成する

ローカルホストポート ​`8081`​ で ​`/as2-receive`​ パスへのコールが行われたときに Mule フローを開始するように、​**AS 2 Listener**​ ソースを設定します。

1. Anypoint Studio で、新しい Mule プロジェクトを作成します。
2. **\[Mule Palette (Mule パレット)\]**​ ビューで、​**\[As 2 listener\]**​ ソースを選択してキャンバスにドラッグします。
3. **\[As 2 listener\]**​ プロパティ画面で、必要に応じて ​**\[Display Name (表示名)\]**​ 項目の値を変更します。
4. **\[Path (パス)\]**​ 項目を ​`/as2-receive`​ に設定します。
5. **\[Connector configuration (コネクタ設定)\]**​ 項目の横にあるプラス記号 (​**+**​) をクリックして、アプリケーション内の ​**As 2 listener**​ ソースのすべてのインスタンスで使用できるグローバル要素を設定します。
6. **\[General (一般)\]**​ タブで、​**\[HTTP Listener\]**​ 項目の横にあるプラス記号 (​**+**​) をクリックします。
7. デフォルトを受け入れて ​**\[OK\]**​ をクリックします。
8. **\[General (一般)\]**​ タブで、証明書とキーを含むキーストアを設定します。
    
    <table class="tableblock frame-all grid-all fit-content spread">
<colgroup>
<col>
<col>
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">項目</th>
<th class="tableblock halign-left valign-top">Value (値)</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Keystore Password (キーストアパスワード)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>test</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Keystore Path (キーストアパス)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>as2/partnera.p12</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Private Key Password (非公開キーパスワード)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>test</code></p></td>
</tr>
</tbody>
</table>
9. **\[Partners (パートナー)\]**​ タブで、自分とパートナーのログイン情報を指定します。
    
    自分のログイン情報で、次の項目を設定します。
    
    <table class="tableblock frame-all grid-all fit-content spread">
<colgroup>
<col>
<col>
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">項目</th>
<th class="tableblock halign-left valign-top">Value (値)</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">AS2 Partner Name (AS2 パートナー名)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>partnera</code>​</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">x509 Alias (x509 別名)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>partnera</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">email (メール)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>support@partnera.com</code></p></td>
</tr>
</tbody>
</table>
    
    パートナーログイン情報で、次の項目を設定します。
    
    <table class="tableblock frame-all grid-all fit-content spread">
<colgroup>
<col>
<col>
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">項目</th>
<th class="tableblock halign-left valign-top">Value (値)</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">AS2 Partner Name (AS2 パートナー名)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>partnerb</code>​</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">x509 Alias (x509 別名)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>partnerb</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">email (メール)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>support@partnerb.com</code></p></td>
</tr>
</tbody>
</table>

### [](#logger-コンポーネントを追加する)Logger コンポーネントを追加する

**Logger**​ コンポーネントをフローに追加し、受信したメッセージのペイロードを含むメッセージをログに記録するように設定します。

1. **\[Mule Palette (Mule パレット)\]**​ ビューから、​**\[Core (コア)\]**​ を選択して ​**\[Logger\]**​ コンポーネントを ​**\[As 2 listener\]**​ の横にドラッグします。
2. \[Logger\] プロパティ画面で、​**\[Message (メッセージ)\]**​ 項目を「​`Message Received: #[payload]`​」(受信したメッセージ: #\[payload\]) に設定します。

### [](#mule-アプリケーションを保存してテストする)Mule アプリケーションを保存してテストする

1. プロジェクトを保存します。
2. **Package Explorer**​ でプロジェクト名をクリックし、​**\[Run (実行)\]**​ > ​**\[Run As (別のユーザーとして実行)\]**​ > ​**\[Mule Application (Mule アプリケーション)\]**​ をクリックして、アプリケーションを実行します。
    
    アプリケーションが正しく起動すると、コンソールに次のメッセージが表示されます。
    
    `Mule is up and kicking`​ (Mule は稼働中です)
3. ブラウザーまたは Postman などのアプリケーションから ​`http://localhost:8081/as2-receive`​ を開き、必要なログイン情報を追加して、アプリケーションをテストします。
    
    新しい要求ごとに、受信したメッセージが Studio コンソールに表示されます。次に例を示します。

```console
INFO  2022-09-09 17:15:46,409 [[MuleRuntime].uber.06: [as2-basic-example].AS2Listener.CPU_LITE @1369de96] [processor:
AS2Listener/processors/0; event: 30609f70-307c-11ed-8f5a-38f9d3713331] org.mule.runtime.core.internal.processor.
LoggerMessageProcessor: Message Received: Test Message
```

### [](#as2-メッセージを受信する-xml-の例)AS2 メッセージを受信する XML の例

この例のフローをすばやく Mule アプリケーションに読み込むには、次のコードを Studio XML エディターに貼り付けます。

```xml
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:http="http://www.mulesoft.org/schema/mule/http"
	xmlns:as2-mule4="http://www.mulesoft.org/schema/mule/as2-mule4" xmlns="http://www.mulesoft.org/schema/mule/core"
	xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/as2-mule4 http://www.mulesoft.org/schema/mule/as2-mule4/current/mule-as2-mule4.xsd">
	<http:listener-config name="HTTP_Server_Config" doc:name="HTTP Listener config" >
		<http:listener-connection host="0.0.0.0" port="8081" />
	</http:listener-config>
	<as2-mule4:listener-config name="AS2_Server_Listener" doc:name="AS2 Connector Listener config" httpListenerConfig="HTTP_Server_Config" securityLevel="SIGNED_ENCRYPTED">
		<as2-mule4:self-config as2Name="partnera" x509Alias="partnera" email="support@partnera.com"/>
		<as2-mule4:partner-config as2Name="partnerb" x509Alias="partnerb" email="support@partnerb.com" />
		<as2-mule4:key-store-config keystorePassword="test" keystorePath="as2/partnera.p12" privateKeyPassword="test" />
	</as2-mule4:listener-config>
	<flow name="AS2Listener" >
		<as2-mule4:as2-listener doc:name="As 2 listener" config-ref="AS2_Server_Listener" path="/as2-receive"/>
		<logger level="INFO" doc:name="Message Received!" message="Message Received: #[payload]"/>
	</flow>
</mule>
```

## [](#synchronous-mdns)同期 AS2 MDN の送信

この例を作成するには、新しい Mule プロジェクトを作成し、​**\[HTTP\] > \[Listener\]**​ ソースと ​**Logger**​ コンポーネントを設定する必要があります。

次のスクリーンショットは、この例の Anypoint Studio アプリケーションフローを示しています。

![同期 AS2 MDN の送信例のアプリケーションフロー](/mulesoft/current/ja-jp/as2-connector/6.8/_images/as2-connector-example-sync-flow.png)

### [](#同期-as2-mdn-メッセージを送信するフローを作成する)同期 AS2 MDN メッセージを送信するフローを作成する

ローカルホストポート ​`8082`​ で ​`/sendSyncFlow`​ パスへのコールが行われたときに Mule フローを開始するように、​**\[HTTP\] > \[Listener\]**​ ソースを設定します。

1. **\[Mule Palette (Mule パレット)\]**​ ビューで、​**\[HTTP\] > \[Listener\]**​ ソースを選択してキャンバスにドラッグします。
2. **\[HTTP\] > \[Listener\]**​ プロパティ画面で、必要に応じて ​**\[Display Name (表示名)\]**​ 項目の値を変更し、​**\[OK\]**​ をクリックします。
3. **\[Path (パス)\]**​ 項目を ​`/sendSyncFlow`​ に設定します。
4. **\[Connector configuration (コネクタ設定)\]**​ 項目の横にあるプラス記号 (​**+**​) をクリックして、アプリケーション内の ​**\[HTTP\] > \[Listener\]**​ ソースのすべてのインスタンスで使用できるグローバル要素を設定します。
5. **\[General (一般)\]**​ タブで、デフォルトを受け入れて ​**\[OK\]**​ をクリックします。

### [](#send-with-sync-mdn-操作を追加する)Send with Sync MDN 操作を追加する

**Send with Sync MDN**​ 操作を追加して、MDN を ​`partnera`​ の受信エンドポイントに送信するように設定します。

1. **\[Send with Sync MDN\]**​ をキャンバスの ​**\[Listener\]**​ の横にドラッグします。
2. **Send with Sync MDN**​ 操作のグローバル要素を設定するために、​**\[Connector configuration (コネクタ設定)\]**​ 項目の横にあるプラス記号 (​**+**​) をクリックします。
3. **\[General (一般)\]**​ タブで、​**\[Partner URL (パートナー URL)\]**​ 項目を ​`http://localhost:8082/as2-receive`​ に設定して、接続を設定します。
4. 自分とパートナーのログイン情報を指定します。
    
    セルフ設定の場合、​**\[Self Config (セルフ設定)\]**​ セクションで次の項目を設定します。
    
    <table class="tableblock frame-all grid-all fit-content spread">
<colgroup>
<col>
<col>
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">項目</th>
<th class="tableblock halign-left valign-top">Value (値)</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">AS2 Partner Name (AS2 パートナー名)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>partnerb</code>​</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">x509 Alias (x509 別名)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>parnerb</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">email (メール)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>support@partnerb.com</code></p></td>
</tr>
</tbody>
</table>
    
    パートナー設定の場合、​**\[Partner Config (パートナー設定)\]**​ セクションで次の項目を設定します。
    
    <table class="tableblock frame-all grid-all fit-content spread">
<colgroup>
<col>
<col>
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">項目</th>
<th class="tableblock halign-left valign-top">Value (値)</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">AS2 Partner Name (AS2 パートナー名)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>partnera</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">x509 Alias (x509 別名)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>parnera</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">email (メール)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>support@partnera.com</code></p></td>
</tr>
</tbody>
</table>
5. 必要に応じて、使用するアルゴリズムを使用して ​**\[Requester Config (リクエスター設定)\]**​ セクションを設定します。
6. **\[Keystore (キーストア)\]**​ セクションで、証明書とキーを含むキーストアを設定します。
    
    <table class="tableblock frame-all grid-all fit-content spread">
<colgroup>
<col>
<col>
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">項目</th>
<th class="tableblock halign-left valign-top">Value (値)</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Keystore Password (キーストアパスワード)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>test</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Keystore Path (キーストアパス)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>as2/partnerb.p12</code></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">Private Key Password (非公開キーパスワード)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>test</code></p></td>
</tr>
</tbody>
</table>

### [](#logger-コンポーネントを追加する-2)Logger コンポーネントを追加する

**Logger**​ コンポーネントをフローに追加し、アプリケーションが同期 MDN を送信したときに Studio コンソールにメッセージを記録するように設定します。

1. **\[Mule Palette (Mule パレット)\]**​ ビューから、​**\[Core (コア)\]**​ を選択して ​**\[Logger\]**​ コンポーネントを ​**\[Send with Sync MDN\]**​ の横にドラッグします。
2. \[Logger\] プロパティ画面で、​**\[Message (メッセージ)\]**​ 項目を「​`Message Sent and MDN Received!`​」(メッセージが送信され、MDN が受信されました!) に設定します。

### [](#mule-アプリケーションを保存してテストする-2)Mule アプリケーションを保存してテストする

1. プロジェクトを保存します。
2. **Package Explorer**​ でプロジェクト名をクリックし、​**\[Run (実行)\]**​ > ​**\[Run As (別のユーザーとして実行)\]**​ > ​**\[Mule Application (Mule アプリケーション)\]**​ をクリックして、アプリケーションを実行します。
    
    アプリケーションが正しく起動すると、コンソールに次のメッセージが表示されます。
    
    `Mule is up and kicking`​ (Mule は稼働中です)
3. ブラウザーまたは Postman などのアプリケーションから ​`http://localhost:8082/sendSyncFlow`​ を開いて、アプリケーションをテストします。
4. これで、​[「AS2 メッセージの受信」](#receiving-messages)​の例で設定されたエンドポイントに AS2 要求を送信できるようになりました。
    
    この例を実行している場合、​**Send with Sync MDN**​ 操作によって送信されたメッセージを確認できます。

### [](#同期-as2-mdn-を送信する-xml-の例)同期 AS2 MDN を送信する XML の例

```xml
<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:as2-mule4="http://www.mulesoft.org/schema/mule/as2-mule4" xmlns:http="http://www.mulesoft.org/schema/mule/http"
	xmlns="http://www.mulesoft.org/schema/mule/core"
	xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/as2-mule4 http://www.mulesoft.org/schema/mule/as2-mule4/current/mule-as2-mule4.xsd">
	<http:listener-config name="HTTP_Client_Config" doc:name="HTTP Listener config" >
		<http:listener-connection host="0.0.0.0" port="8082" />
	</http:listener-config>
	<as2-mule4:send-config name="AS2_Client_Send_Sync" doc:name="AS2 Connector Send config" >
		<as2-mule4:connection partnerURL="http://localhost:8081/as2-receive" />
		<as2-mule4:self-config as2Name="partnerb" x509Alias="partnerb" email="support@partnerb.com" />
		<as2-mule4:partner-config as2Name="partnera" x509Alias="partnera" email="support@partnera.com" />
		<as2-mule4:requester-config messageIntegrityCheckAlgorithm="SHA512" mdnMessageIntegrityCheckAlgorithm="SHA512" encryptionAlgorithm="DES_EDE3" requestReceipt="SIGNED_REQUIRED" />
		<as2-mule4:keystore-config keystorePassword="test" keystorePath="as2/partnerb.p12" privateKeyPassword="test" />
	</as2-mule4:send-config>
	<flow name="SendSyncFlow" >
		<http:listener doc:name="/sendAsyncFlow" config-ref="HTTP_Client_Config" path="/sendAsyncFlow" />
		<as2-mule4:send-with-sync-mdn doc:name="Send with Sync MDN" config-ref="AS2_Client_Send_Sync"/>
		<logger level="INFO" doc:name="Message Sent and MDN Received!" message="Message Sent and MDN Received!" />
	</flow>
</mule>
```

## [](#asynchronous-mdns)非同期 AS2 MDN の送信

この例は、​[「AS2 同期 MDN の送信」](#synchronous-mdns)​の例と似ていますが、次の点が異なります。

- **Send with Sync MDN**​ 操作の代わりに ​**Send with Async MDN**​ 操作を使用する。
- **\[Receipt delivery url (受信確認配信 URL)\]**​ 項目の値を指定する必要がある。
    
    この項目は、​**Send with Async MDN**​ 操作のグローバル要素、またはその操作のプロパティウィンドウでグローバルに設定できます。

次のスクリーンショットは、この例の Studio アプリケーションフローを示しています。

![非同期 AS2 MDN の送信例のアプリケーションフロー](/mulesoft/current/ja-jp/as2-connector/6.8/_images/as2-connector-example-async-flow.png)

### [](#as2-非同期-mdn-を送信する-xml-の例)AS2 非同期 MDN を送信する XML の例

この例のフローをすばやく Mule アプリケーションに読み込むには、次のコードを Studio XML エディターに貼り付けます。

```xml
<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:as2-mule4="http://www.mulesoft.org/schema/mule/as2-mule4" xmlns:http="http://www.mulesoft.org/schema/mule/http"
	xmlns="http://www.mulesoft.org/schema/mule/core"
	xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/as2-mule4 http://www.mulesoft.org/schema/mule/as2-mule4/current/mule-as2-mule4.xsd">
	<http:listener-config name="HTTP_Client_Config" doc:name="HTTP Listener config" >
		<http:listener-connection host="0.0.0.0" port="8082" />
	</http:listener-config>
	<as2-mule4:send-config name="AS2_Client_Send_Sync" doc:name="AS2 Connector Send config" >
		<as2-mule4:connection partnerURL="http://localhost:8081/as2-receive" />
		<as2-mule4:self-config as2Name="partnerb" x509Alias="partnerb" email="support@partnerb.com" />
		<as2-mule4:partner-config as2Name="partnera" x509Alias="partnera" email="support@partnera.com" />
		<as2-mule4:requester-config messageIntegrityCheckAlgorithm="SHA512" mdnMessageIntegrityCheckAlgorithm="SHA512" encryptionAlgorithm="DES_EDE3" requestReceipt="SIGNED_REQUIRED" />
		<as2-mule4:keystore-config keystorePassword="test" keystorePath="as2/partnerb.p12" privateKeyPassword="test" />
	</as2-mule4:send-config>
	<flow name="SendSyncFlow" >
		<http:listener doc:name="/sendSyncFlow" config-ref="HTTP_Client_Config" path="/sendSyncFlow" />
		<as2-mule4:send-with-async-mdn doc:name="Send with Async MDN" config-ref="AS2_Client_Send_Sync" receiptDeliveryUrl="http://localhost:8082/recieveMDN"/>
		<logger level="INFO" doc:name="Message Sent!" message="Message Sent!" />
	</flow>
</mule>
```

## [](#関連情報)関連情報

- [AS2 Connector の例](https://docs.mulesoft.com/jp/as2-connector/6.8/as2-connector-examples)
- [Anypoint Connector の概要](https://docs.mulesoft.com/connectors/introduction/introduction-to-anypoint-connectors)
- [MuleSoft ヘルプセンター](https://help.mulesoft.com)