ListInventory 操作で型付けされたエラーを表示するようにします。tshirt2.wsdl ファイルには、WSDL 操作にマップされる TshirtFault 型のエラーが含まれています。
-
OrderTshirt -
ListInventory -
TrackOrder
APIkit for SOAP は、次の種別の SOAP エラーをサポートしています。
-
Soap Fault 1.1
-
Soap Fault 1.2
型付けされたエラーが含まれないファイルでも、任意の WSDL ファイルを使用していずれかの種別を選択できます。
-
Anypoint Studio で、コマンドパレット内の fault を検索します。
複数の
SOAP Fault コンポーネントが表示される場合があります。 -
SOAP Fault を ListInventory:api-config フローにドラッグします。「Operation Unavailable (操作は使用できません)」メッセージが表示された場合、操作をキャンセルして別の
SOAP Fault コンポーネントを選択します。 -
バージョンの一致が見つかるまで、この手順を繰り返します。
-
プロパティエディターの [Module Configuration (モジュール設定)] で、
soapkit-config を選択します。 -
[Operation (操作)]で、
ListInventory を選択します。 -
[Fault (エラー)] で、
Fault を選択します。 -
プロパティを保存します。
-
Transform Message コンポーネントを選択します。 -
DataWeave コードを次のように変更します。
%dw 2.0 output application/xml ns ns0 http://mulesoft.org/tshirt-service ns soap http://schemas.xmlsoap.org/soap/envelope/ --- { soap#Fault: { faultcode: "soap:Server", faultstring: "The error details", detail: { ns0#TshirtFault: { errorStuff: 500 } } } } -
プロジェクトを保存して、もう一度実行します。
SoapUI を使用して、
ListInventory 操作を実行します。クライアントは、デフォルトのエラーの代わりに次のエンベロープを返します。
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <soap:Fault> <faultcode>soap:Server</faultcode> <faultstring>The error details</faultstring> <detail> <ns0:TshirtFault xmlns:ns0="http://mulesoft.org/tshirt-service"> <errorStuff>500</errorStuff> </ns0:TshirtFault> </detail> </soap:Fault> </soap:Body> </soap:Envelope>