---
schema_version: "1"
id: 73ce03e758d88af2aaf4c2faa774ddb366e83c8762633aeae44acd0de96d10af
title: Web Service Consumer の追加設定情報
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/web-service-consumer-connector/1.9/web-service-consumer-config-topics.md
canonical_url: https://docs.mulesoft.com/jp/web-service-consumer-connector/1.9/web-service-consumer-config-topics
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 483e3369af4503a96c6177088d726075d907637fa60bc3ec290106bdd62dcf7a
description: MuleSoft Documentation Site
release: "1.9"
latest: false
---
# Web Service Consumer の追加設定情報

Anypoint Studio と XML エディターの両方でカスタム HTTP トランスポートや Web サービスセキュリティなど、Web サービスコンシューマー用 Anypoint Connector (Web Service Consumer Connector) の追加設定を定義します。

## [](#カスタム-http-トランスポートを設定する)カスタム HTTP トランスポートを設定する

デフォルトでは、コネクタは単純な保護されていない HTTP 設定を使用して、すべての送信 SOAP メッセージをディスパッチします。詳細な HTTP 設定が必要な場合、メッセージをディスパッチするために HTTP Connector 設定を使用して Web Service Consumer Connector をパラメーター化できます。

次の例では、コネクタで各要求がディスパッチされるように Web Service Consumer Connector 設定の ​**\[Transport Configuration (トランスポート設定)\]**​ パラメーターで HTTP 基本認証を使用して HTTP リクエスター設定を宣言して参照する方法を示しています。

1. Studio で Web Service Consumer Connector の ​**\[Global Element Properties (グローバル要素のプロパティ)\]**​ ウィンドウを開きます。
2. **\[Transport (トランスポート)\]**​ タブで、​**\[Transport Configuration (トランスポート設定)\]**​ に ​`HTTP Transport Configuration`​ を選択します。  
    **\[Requester Config (リクエスター設定)\]**​ 項目に自動的に ​`HTTP_Request_configuration`​ が入力されるのは、以前に HTTP 要求設定を作成した場合のみです。
3. **\[OK\]**​ をクリックします。

Studio での HTTP トランスポートの設定は次のようになります。

![カスタム HTTP トランスポートを設定する](/mulesoft/current/ja-jp/web-service-consumer-connector/1.9/_images/web-service-consumer-configure-transport.png)

**\[Configuration XML (設定 XML)\]**​ タブで、HTTP リクエスター設定 ​`<http:request-config name="HTTP_Request_configuration">`​ の参照は Web サービスコンシューマー設定 ​`<wsc:custom-transport-configuration>`​ の下にあります。

```xml
<http:request-config name="HTTP_Request_configuration">
    <http:request-connection host="www.exampleplace.com" port="8182" protocol="HTTP">
        <http:authentication>
            <http:basic-authentication username="admin" password="textpassword"/>
        </http:authentication>
    </http:request-connection>
</http:request-config>

<wsc:config name="with-custom-transport">
    <wsc:connection wsdlLocation="http://www.host.com?WSDL" service="Service" port="Port">
        <wsc:custom-transport-configuration>
            <wsc:http-transport-configuration requesterConfig="basic-auth"/>
        </wsc:custom-transport-configuration>
    </wsc:connection>
</wsc:config>
```

## [](#web-サービスセキュリティの設定)Web サービスセキュリティの設定

WS-Security プロトコルにより、さまざまなセキュリティトークン形式を使用してメッセージの整合性および機密性を適用できます。このプロトコルでは、エンドツーエンドセキュリティを提供するために XML 署名と XML 暗号化を使用します。

WS-Security は、次の方法を記述します。

- 整合性を確保して非否認を提供するために SOAP メッセージに署名する。
- 機密性を確保するために SOAP メッセージを暗号化する。
- 送信者の ID を確認するためにセキュリティトークンを添付する。

Web Service Consumer Connector は、次のメカニズムをサポートします。

- Timestamp (タイムスタンプ)
- 署名または署名検証
- Username (ユーザー名)
- 暗号化または復号化

次の例では、コネクタの Web サービスセキュリティのユーザー名トークンセキュリティ戦略を設定する方法を示しています。

1. Studio で Web Service Consumer Connector の ​**\[Global Element Properties (グローバル要素のプロパティ)\]**​ ウィンドウを開きます。
2. **\[Security (セキュリティ)\]**​ タブで、​**\[Username token security strategy (ユーザー名トークンセキュリティ戦略)\]**​ に ​`Edit inline`​ を選択します。
3. **\[Username (ユーザー名)\]**​ 項目と ​**\[Password (パスワード)\]**​ 項目に入力し、​**\[Add nonce (ノンスを追加)\]**​ 項目と ​**\[Add created (作成済みを追加)\]**​ 項目を ​`true`​ に設定します。
4. **\[OK\]**​ をクリックします。

Studio での Web サービスセキュリティの設定は次のようになります。

![Web サービスセキュリティの設定](/mulesoft/current/ja-jp/web-service-consumer-connector/1.9/_images/web-service-consumer-configure-wsecurity.png)

**\[Configuration XML (設定 XML)\]**​ タブでは、Web サービスセキュリティの設定は次のように記述されます。

```xml
<wsc:config name="with-custom-transport">
    <wsc:connection wsdlLocation="http://www.host.com?WSDL" service="Service" port="Port">
        <wsc:web-service-security>
            <wsc:username-token-security-strategy username="admin" password="textPassword" addCreated="true" addNonce="true"/>
        </wsc:web-service-security>
    </wsc:connection>
</wsc:config>
```

## [](#wscempty_response-エラーを設定する)WSC:EMPTY\_RESPONSE​ エラーを設定する

応答に必須項目がない場合 (無効な空の応答)、Web Service Consumer Connector の ​`WSC:EMPTY_RESPONSE`​ エラーをスローするように ​**Error Handler**​ コンポーネントを設定できます。

1. Studio で、\[Error handling (エラー処理)\] セクションの ​**\[On Error Continue\]**​ コンポーネントを選択します。
2. **\[Type (種別)\]**​ を ​**WSC:EMPTY\_RESPONSE**​ に設定します。

![「Type (種別)」 項目に選択された WSC:EMPTY\_RESPONSE](/mulesoft/current/ja-jp/web-service-consumer-connector/1.9/_images/web-service-consumer-emptyresponse.png)

**\[Configuration XML (設定 XML)\]**​ タブでは、設定は次のように記述されます。

```xml
<flow name="WSC-Example">
  <scheduler>
    <scheduling-strategy >
      <fixed-frequency />
    </scheduling-strategy>
  </scheduler>
  <set-variable value="test" variableName="variableSample"/>
  <ee:transform>
    <ee:message >
      <ee:set-payload ><![CDATA[ %dw 2.0
output application/xml
ns con http://service.soap.service.mule.org/
---
con#attachOperation: {
    text: vars.variableSample
}]]></ee:set-payload>
    </ee:message>
  </ee:transform>
  <wsc:consume config-ref="Web_Service_Consumer_Config" operation="attachOperation">
    <wsc:message-customizations forceXMLProlog="true"/>
  </wsc:consume>
    <error-handler >
      <on-error-continue enableNotifications="true" logException="true" type="WSC:EMPTY_RESPONSE">
      <logger level="INFO" message="The response was empty." />
      </on-error-continue>
    </error-handler>
</flow>
```

## [](#失敗シナリオで属性を読み取る)失敗シナリオで属性を読み取る

次の例は、失敗シナリオで SOAP 属性または追加トランスポートデータ属性を読み取るように Web Service Consumer Connector を設定する方法を示しています。

1. Studio で、​**\[Scheduler\]**​ ソースをフローにドラッグします。
2. **\[Set variable\]**​ コンポーネントを ​**\[List\]**​ ソースの横にドラッグします。
3. **\[Name (名前)\]**​ を ​`variableSample`​ に、​**\[Value (値)\]**​ を ​`test`​ に設定します。
4. **\[Transform Message\]**​ コンポーネントを ​**\[Set Variable\]**​ コンポーネントの横にドラッグします。
5. Datasense 出力ビューで、次の DataWeave 式を追加します。

```dataweave
 %dw 2.0
output application/xml
ns con http://service.soap.service.mule.org/
---
con#attachOperation: {
    text: vars.variableSample
}
```

1. Web Service Consumer Connector の ​**\[Consume\]**​ 操作を ​**\[Transform Message\]**​ コンポーネントの横にドラッグします。
2. コネクタの ​**\[Connector configuration (コネクタ設定)\]**​ を選択します。
3. **\[Operation (操作)\]**​ を ​`attachOperation`​ に設定します。
4. **\[On Error Continue\]**​ コンポーネントをフローの \[Error handling (エラー処理)\] セクションにドラッグします。
5. **\[Type (種別)\]**​ を ​`WSC:BAD_RESPONSE`​ に設定します。
6. **\[Logger\]**​ コンポーネントを ​**\[On Error Continue\]**​ コンポーネントにドラッグします。
7. **\[Message (メッセージ)\]**​ を式 ​`#[error.additionalData.statusCode]`​ に設定して、SOAP 属性または追加トランスポートデータを読み取ります。

**\[Configuration XML (設定 XML)\]**​ タブでは、設定は次のように記述されます。

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

<mule xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core"
	xmlns:wsc="http://www.mulesoft.org/schema/mule/wsc" xmlns:compression="http://www.mulesoft.org/schema/mule/compression"
	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/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/compression http://www.mulesoft.org/schema/mule/compression/current/mule-compression.xsd
http://www.mulesoft.org/schema/mule/wsc http://www.mulesoft.org/schema/mule/wsc/current/mule-wsc.xsd">
	<flow name="WSC-Example">
  <scheduler>
    <scheduling-strategy >
      <fixed-frequency />
    </scheduling-strategy>
  </scheduler>
  <set-variable value="test" variableName="variableSample"/>
  <ee:transform>
    <ee:message >
      <ee:set-payload ><![CDATA[ %dw 2.0
output application/xml
ns con http://service.soap.service.mule.org/
---
con#attachOperation: {
    text: vars.variableSample
}]]></ee:set-payload>
    </ee:message>
  </ee:transform>
  <wsc:consume config-ref="Web_Service_Consumer_Config" operation="attachOperation">
    <wsc:message-customizations forceXMLProlog="true"/>
  </wsc:consume>
    <error-handler >
      <on-error-continue enableNotifications="true" logException="true" type="WSC:BAD_RESPONSE">
      <logger level="INFO" message="#[error.additionalData.statusCode]" />
      </on-error-continue>
    </error-handler>
</flow>
	</flow>
</mule>
```

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

- [MuleSoft ヘルプセンター](https://help.mulesoft.com)
- [Web Service Consumer Connector リファレンス](https://docs.mulesoft.com/jp/web-service-consumer-connector/1.9/web-service-consumer-reference)