---
schema_version: "1"
id: 90c4e5bffc036e64d56b631f058500f48021f88c1d4217af79b5172bbe048261
title: ブラウザーからのアプリケーションの開始の例
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/http-connector/1.10/http-start-app-brows-task.md
canonical_url: https://docs.mulesoft.com/jp/http-connector/1.10/http-start-app-brows-task
source_site: docs.mulesoft.com
content_type: documentation
content_hash: d0989f1e2fbf00405fa697839975af2bc5d3e8baca35aac8517c1c97dd568ea1
description: MuleSoft Documentation Site
release: "1.10"
latest: true
---
# ブラウザーからのアプリケーションの開始の例

次の例は、フローを開始するように HTTP 用 Anypoint Connector (HTTP Connector) の ​**Listener**​ ソースを設定する方法を示しています。この例では、HTTP ​**Listener**​ ソースによって特定のポートでサーバー上の全ネットワークインターフェースがリスンされます。次に、​**Logger**​ コンポーネントによってメッセージ ​`Hello`​ が記録されます。 この例を実行するには、Mule アプリケーションを作成し、HTTP グローバル要素を設定し、アプリケーションを実行し、curl コマンドでアプリケーションをテストする必要があります。

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

![ブラウザーからのアプリケーションの開始のフロー](/mulesoft/current/ja-jp/http-connector/1.10/_images/http-startapp-flow.png)

## [](#mule-アプリケーションの作成)Mule アプリケーションの作成

Mule フローを作成する手順は、次のとおりです。

1. **\[Mule Palette (Mule パレット)\]**​ ビューで、\[HTTP\] の ​**\[Listener\]**​ ソースを選択してキャンバスにドラッグします。  
    このソースは受信 HTTP メッセージ属性をリスンすることでフローを開始します。
2. **\[Listener (リスナー)\]**​ 設定画面で、必要に応じて ​**\[Display Name (表示名)\]**​ 項目の値を変更します。
3. Web ブラウザーからアプリケーションを開始するように ​**\[Path (パス)\]**​ 項目を ​`/trigger`​ に設定します。
4. **\[Connector configuration (コネクタ設定)\]**​ 項目の横にあるプラス記号 (​**+**​) をクリックして、アプリケーション内の HTTP ​**Listener**​ のすべてのインスタンスで使用できるグローバル要素を設定します。
5. **\[General (一般)\]**​ タブで、次の項目を設定します。
    
    - **Host (ホスト)**​  
        `All Interfaces [0.0.0.0] (default)`
    - **Port (ポート)**​  
        `8081`
6. **\[OK\]**​ をクリックします。
    
    ![HTTP リスナーのグローバル設定](/mulesoft/current/ja-jp/http-connector/1.10/_images/http-startapp-example-1.png)
    
    ![HTTP リスナーの設定](/mulesoft/current/ja-jp/http-connector/1.10/_images/http-startapp-example-2.png)
7. **\[Logger\]**​ コンポーネントを \[HTTP\] の ​**\[Listener\]**​ の右にドラッグします。
8. **\[Logger\]**​ 設定画面で、​**\[Message (メッセージ)\]**​ 項目を ​`Hello`​ に設定します。
    
    ![Logger の設定](/mulesoft/current/ja-jp/http-connector/1.10/_images/http-startapp-example-3.png)
9. Mule アプリケーションを保存します。
10. **Package Explorer**​ でプロジェクト名をクリックし、​**\[Run (実行)\]**​ > ​**\[Run As (別のユーザーとして実行)\]**​ > ​**\[Mule Application (Mule アプリケーション)\]**​ をクリックします。  
    メッセージ ​`Mule is up and kicking`​ を検索し、コンソールメッセージにアプリケーションが適切に起動したことが示されていることを確認します。
11. ブラウザーを開き、​`http://0.0.0.0:8081/trigger`​ と入力します。  
    HTTP ​**Listener**​ ソースがポート ​`8081`​ で要求をリスンすると、アプリケーションが起動されます。
12. Studio コンソールで、ログをスクロールすると次のような ​`Hello`​ メッセージが表示されます。

```console
INFO  2020-01-02 13:00:00,438 [[MuleRuntime].cpuLight.15: [http].httpFlow.CPU_LITE @169a1097]
  [event: id] org.mule.runtime.core.internal.processor.LoggerMessageProcessor: Hello
```

## [](#ブラウザーからアプリケーションを開始するための-xml)ブラウザーからアプリケーションを開始するための XML

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

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

<mule 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:listener-config name="HTTP_Listener_config" >
		<http:listener-connection host="0.0.0.0" port="8081" />
	</http:listener-config>
	<flow name="flow" >
		<http:listener doc:name="Listener" config-ref="HTTP_Listener_config" path="/trigger"/>
		<logger level="INFO" doc:name="Logger" message="Hello"/>
	</flow>
</mule>
```

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

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