---
schema_version: "1"
id: 42c3eaee7419724ec4d1697c89abcf6e6ff223665dbdf844186a8ca771abe16e
title: Apply 操作の例
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/wss-module/2.0/apply-wss-examples.md
canonical_url: https://docs.mulesoft.com/jp/wss-module/2.0/apply-wss-examples
source_site: docs.mulesoft.com
content_type: documentation
content_hash: a68e1540a50998d0858958ea56cb3e400de09a1ead2664c78dae0d55608db2ab
description: MuleSoft Documentation Site
release: "2.0"
latest: true
---
# Apply 操作の例

`apply`​ 操作は、​`WssOutboundConfig`​ で指定されている設定に従って WSS 情報を SOAP 応答に適用します。

<table class="tableblock frame-all grid-all fit-content spread">
<caption class="title">Table 1. パラメーター</caption>
<colgroup>
<col>
<col>
<col>
<col>
<col>
<col>
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">名前</th>
<th class="tableblock halign-left valign-top">M</th>
<th class="tableblock halign-left valign-top">ES</th>
<th class="tableblock halign-left valign-top">デフォルト値</th>
<th class="tableblock halign-left valign-top">型</th>
<th class="tableblock halign-left valign-top">説明</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>response</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">はい</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">いいえ</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">-</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>TypedValue &lt;InputStream&gt;</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">SOAP response (SOAP 応答)</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>version</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">いいえ</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">はい</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>SOAP_12</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>SoapVersion</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">SOAP バージョン: <code>SOAP_11</code>​ または ​<code>SOAP_12</code></p></td>
</tr>
</tbody>
</table>

出力は、アウトバウンド設定を適用した結果のヘッダー要素 ​`<wsse:Security></wsse:Security>`​ を含む SOAP 応答です。この操作は何も属性を返しません。

<table class="tableblock frame-all grid-all fit-content spread">
<caption class="title">Table 2. Errors (エラー)</caption>
<colgroup>
<col>
<col>
<col>
<col>
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Namespace (名前空間)</th>
<th class="tableblock halign-left valign-top">型</th>
<th class="tableblock halign-left valign-top">親</th>
<th class="tableblock halign-left valign-top">説明</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">WSS</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">SECURITY_APPLYING</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">適用なし</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">応答で WSS の適用に失敗した場合にスローされます。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">WSS</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">MISSING_CERTIFICATE</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">適用なし</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">トラストストアまたはキーストアのどちらからも証明書を取得できない場合にスローされます。</p></td>
</tr>
</tbody>
</table>

## [](#encrypt)暗号化

<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
<div class="paragraph">
<p>暗号化操作を実行する場合には、メッセージのペイロードに変換を適用しないでください。変換操作では、暗号化署名が除外されません。</p>
</div>
</td>
</tr>
</tbody></table>

次の例は、キーストアを使用して暗号化を適用する方法を示しています。

暗号化の例

```XML
<wss:outbound-config name="encryption-config">
	<wss:encryption-config>
		<wss:keystore-config path="certificates/sign-keystore.jks"
password="mulepassword"
alias="muleclient"
keyPassword="mulepassword" />
	</wss:encryption-config>
</wss:outbound-config>

<flow name="OrderTshirtServiceFlow">
	<http:listener config-ref="HTTP-listener-config" path="/order" />
	<flow-ref name="OrderTshirtFlowImpl" />
	<wss:apply-wss config-ref="encryption-config" version="SOAP_12"/>
</flow>
```

## [](#signature)署名

<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
<div class="paragraph">
<p>暗号化操作を実行する場合には、メッセージのペイロードに変換を適用しないでください。変換操作では、暗号化署名が除外されません。</p>
</div>
</td>
</tr>
</tbody></table>

次の例は、キーストアと ​`RSAwithSHA1`​ アルゴリズムを使用して SOAP メッセージに署名する方法を示しています。

署名の例

```XML
<wss:outbound-config name="sign-config">
	<wss:signature-config algorithm="RSAwithSHA1" >
		<wss:keystore-config path="certificates/sign-keystore.jks"
                            	password="mulepassword"
					alias="muleclient"
       	                    keyPassword="mulepassword" />
	</wss:signature-config>
</wss:outbound-config>

<flow name="OrderTshirtServiceFlow">
	<http:listener config-ref="HTTP-listener-config" path="/order" />
	<flow-ref name="OrderTshirtFlowImpl" />
	<wss:apply-wss config-ref="sign-config" version="SOAP_12"/>
</flow>
```

## [](#encryption-signing-certificate)証明書の暗号化と署名

<table>
<tbody><tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
<div class="paragraph">
<p>暗号化操作を実行する場合には、メッセージのペイロードに変換を適用しないでください。変換操作では、暗号化署名が除外されません。</p>
</div>
</td>
</tr>
</tbody></table>

次の例では、署名された要求を検証し、署名証明書を保存して、後でその証明書を ​`apply-wss`​ 操作で使用して応答に署名しています。

要求の例

```XML
<soapenv:Envelope xmlns:ser="http://service.soap.service.mule.org/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Header><wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.1.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.1.xsd"><ds:Signature Id="SIG-F8FAC4A91BEF76355615530303348205" xmlns:ds="http://www.w3.org/2000/09/xmldsig#"><ds:SignedInfo><ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"><ec:InclusiveNamespaces PrefixList="ser soapenv" xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#"/></ds:CanonicalizationMethod><ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/><ds:Reference URI="#id-F8FAC4A91BEF76355615530303348174"><ds:Transforms><ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"><ec:InclusiveNamespaces PrefixList="ser" xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#"/></ds:Transform></ds:Transforms><ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><ds:DigestValue>yLFLEkH4/MjYbZ4viZxjou9/4os=</ds:DigestValue></ds:Reference></ds:SignedInfo><ds:SignatureValue>xxxxx+xxxxxxxxx==</ds:SignatureValue><ds:KeyInfo Id="KI-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"><wsse:SecurityTokenReference wsu:Id="STR-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"><ds:X509Data><ds:X509IssuerSerial><ds:X509IssuerName>CN=Unknown,OU=Unknown,O=Unknown,L=Unknown,ST=Unknown,C=US</ds:X509IssuerName><ds:X509SerialNumber>1545521240</ds:X509SerialNumber></ds:X509IssuerSerial></ds:X509Data></wsse:SecurityTokenReference></ds:KeyInfo></ds:Signature></wsse:Security></soapenv:Header>
   <soapenv:Body wsu:Id="id-F8FAC4A91BEF76355615530303348174" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.1.xsd">
      <ser:echo>
         <text>test</text>
      </ser:echo>
   </soapenv:Body>
</soapenv:Envelope>
```

暗号化の例

```XML
<wss:inbound-config name="validate-signature-config">
   <wss:verify-signature-config>
       <wss:truststore-config path="certificates/verify-signature-truststore.jks"
					password="mulepassword" />
   </wss:verify-signature-config>
</wss:inbound-config>

<wss:outbound-config name="encryption-without-keystore-config">
   <wss:encryption-config />
</wss:outbound-config>

<flow name="OrderTshirtServiceFlow">
	<http:listener config-ref="HTTP-listener-config" path="/order" />
	<wss:validate-wss config-ref="validate-signature-config" version="SOAP_12" />
	<flow-ref name="OrderTshirtFlowImpl" />
	<wss:apply-wss config-ref="encryption-without-keystore-config"
					version="SOAP_12" />
</flow>
```