13.9.7. Object Graph Navigation ライブラリーの使用
以下のメッセージでは、customerOrder.header.customerNumber パラメーターを表す OGNL 式は customerOrder.header.customerNumber です。
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:cus="http://schemas.acme.com">
<soapenv:Header/>
<soapenv:Body>
<cus:customerOrder>
<cus:header>
<cus:customerNumber>123456</cus:customerNumber>
</cus:header>
</cus:customerOrder>
</soapenv:Body>
</soapenv:Envelope>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:cus="http://schemas.acme.com">
<soapenv:Header/>
<soapenv:Body>
<cus:customerOrder>
<cus:header>
<cus:customerNumber>123456</cus:customerNumber>
</cus:header>
</cus:customerOrder>
</soapenv:Body>
</soapenv:Envelope>
OGNL 式がパラメーターに対して計算されると、このクラスは、提供されたパラメーターマップで、完全な OGNL 式(上記のオプション 1)から指定されたオブジェクトキーをチェックします。そのようなパラメーターオブジェクトがマップに存在しない場合は、このクラスはマップおよび OGNL 式インスタンスを OGNL ツールキットに指定して、パラメーターの読み込みを試みます。これによって値が得られない場合、SOAP メッセージ内のこのパラメーターの場所は空白になります。
上記のサンプルメッセージを取り、customerNumber を入力するには、オブジェクトインスタンス(たとえば、Order オブジェクトインスタンス)をキー customerOrder キー下のパラメーターマップに設定する必要があります。"customerOrder" オブジェクトインスタンスにはヘッダープロパティー(たとえば、Header オブジェクトインスタンス)を含める必要があります。header プロパティーの背後にあるオブジェクトインスタンス(たとえば、Header オブジェクトインスタンス)には customerNumber プロパティーが必要です。
コレクションに関連付けられた OGNL 式は、若干異なる方法で構築されます。
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:cus="http://schemas.active-endpoints.com/sample/customerorder/2006/04/CustomerOrder.xsd"
xmlns:stan="http://schemas.active-endpoints.com/sample/standardtypes/2006/04/StandardTypes.xsd">
<soapenv:Header/>
<soapenv:Body>
<cus:customerOrder>
<cus:items>
<cus:item>
<cus:partNumber>FLT16100</cus:partNumber>
<cus:description>Flat 16 feet 100 count</cus:description>
<cus:quantity>50</cus:quantity>
<cus:price>490.00</cus:price>
<cus:extensionAmount>24500.00</cus:extensionAmount>
</cus:item>
<cus:item>
<cus:partNumber>RND08065</cus:partNumber>
<cus:description>Round 8 feet 65 count</cus:description>
<cus:quantity>9</cus:quantity>
<cus:price>178.00</cus:price>
<cus:extensionAmount>7852.00</cus:extensionAmount>
</cus:item>
</cus:items>
</cus:customerOrder>
</soapenv:Body>
</soapenv:Envelope>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:cus="http://schemas.active-endpoints.com/sample/customerorder/2006/04/CustomerOrder.xsd"
xmlns:stan="http://schemas.active-endpoints.com/sample/standardtypes/2006/04/StandardTypes.xsd">
<soapenv:Header/>
<soapenv:Body>
<cus:customerOrder>
<cus:items>
<cus:item>
<cus:partNumber>FLT16100</cus:partNumber>
<cus:description>Flat 16 feet 100 count</cus:description>
<cus:quantity>50</cus:quantity>
<cus:price>490.00</cus:price>
<cus:extensionAmount>24500.00</cus:extensionAmount>
</cus:item>
<cus:item>
<cus:partNumber>RND08065</cus:partNumber>
<cus:description>Round 8 feet 65 count</cus:description>
<cus:quantity>9</cus:quantity>
<cus:price>178.00</cus:price>
<cus:extensionAmount>7852.00</cus:extensionAmount>
</cus:item>
</cus:items>
</cus:customerOrder>
</soapenv:Body>
</soapenv:Envelope>
上記の注文メッセージには、注文の項目のコレクションが含まれています。コレクションの各エントリーは、item 要素で表されます。注文アイテム "partNumber" の OGNL 式は、customerOrder.items[0].partnumber および "customerOrder.items[1].partnumber" として構築されます。これから分かるように、コレクションエントリー要素(item 要素)は OGNL 式で明示的な表示を行いません。これは、インデックス表記によって暗黙的に表されます。オブジェクトグラフの観点では、これは、リストエントリーが "OrderItem" インスタンスである "items" リストまたは配列を含む注文オブジェクトインスタンス(マップ上でキーが customerOrder として指定)で表現できます。これには、partNumber およびその他のプロパティーが含まれます。
構築および設定される SOAP メッセージテンプレートを表示するには、dumpSOAP パラメーターをパラメーターマップに追加します。
警告
これは非常に便利な開発者である可能性がありますが、開発の外に置かないでください。