services.xmlでのMTOM有効化について
気が向いたので、またAxis2でMTOMを試していた。
今回はサーバ側からバイナリをダウンロードするサービスを作り、動作させてみたが、
やっぱり"enableMTOM"パラメータはオペレーションごとに設定しても問題無いようだ。
この件についても、改めて調べてみるとAxis2のサイトに記載されていたが、
恐らく見落としていたのだろう。とにかく安心した。
以下のコードは、試しに作成したサービスの"services.xml"である。
このサービスのオペレーションは"MTOMTestDl"と"MTOMTestLs"の2つであり、
"MTOMTestDl"がMTOMを利用してサーバからバイナリデータをダウンロードする
オペレーションであり、"MTOMTestLs"の方は単にファイルの一覧をテキストとして
得るオペレーションである。
<?xml version="1.0" encoding="UTF-8"?> <!-- This file was auto-generated from WSDL --> <!-- by the Apache Axis2 version: 1.5.1 Built on : Oct 19, 2009 (10:59:00 EDT) --> <serviceGroup> <service name="MTOMTestDl"> <messageReceivers> <messageReceiver mep="http://www.w3.org/ns/wsdl/in-out" class="org.apache.ws.axis2.mtom_test_dl.MTOMTestDlMessageReceiverInOut"/> </messageReceivers> <parameter name="ServiceClass">org.apache.ws.axis2.mtom_test_dl.MTOMTestDlSkeleton</parameter> <parameter name="useOriginalwsdl">true</parameter> <parameter name="modifyUserWSDLPortAddress">true</parameter> <operation name="MTOMTestDl" mep="http://www.w3.org/ns/wsdl/in-out" namespace="http://ws.apache.org/axis2/mtom_test_dl/"> <parameter name="enableMTOM">true</parameter> <actionMapping>http://schemas.xmlsoap.org/wsdl/MTOMTestDlServicePortType/MTOMTestDlRequest</actionMapping> <outputActionMapping>//schemas.xmlsoap.org/wsdl/MTOMTestDlServicePortType/MTOMTestDlResponse</outputActionMapping> </operation> <operation name="MTOMTestLs" mep="http://www.w3.org/ns/wsdl/in-out" namespace="http://ws.apache.org/axis2/mtom_test_dl/"> <actionMapping>http://schemas.xmlsoap.org/wsdl/MTOMTestDlServicePortType/MTOMTestLsRequest</actionMapping> <outputActionMapping>//schemas.xmlsoap.org/wsdl/MTOMTestDlServicePortType/MTOMTestLsResponse</outputActionMapping> </operation> </service> </serviceGroup>
少々分かりにくいが、"MTOMTestDl"の方には"enableMTOM"パラメータがあり、
"MTOMTestLs"の方には"enableMTOM"パラメータが無い。
この記述により、"MTOMTestDl"に対してのみMTOMが有効となり、サーバからの
データがMIME形式となる。
一方、"MTOMTestLs"の方はMTOMが有効でないため、サーバからのデータは
単純なSOAPメッセージとなる。
尚、以下のように"enableMTOM"パラメータをoperationタグの外に出すと、
全てのオペレーションに対してMTOMが有効となる。
<serviceGroup> <service name="MTOMTestDl"> <messageReceivers> <messageReceiver mep="http://www.w3.org/ns/wsdl/in-out" class="org.apache.ws.axis2.mtom_test_dl.MTOMTestDlMessageReceiverInOut"/> </messageReceivers> <parameter name="ServiceClass">org.apache.ws.axis2.mtom_test_dl.MTOMTestDlSkeleton</parameter> <parameter name="useOriginalwsdl">true</parameter> <parameter name="modifyUserWSDLPortAddress">true</parameter> <parameter name="enableMTOM">true</parameter> <operation name="MTOMTestDl" mep="http://www.w3.org/ns/wsdl/in-out" namespace="http://ws.apache.org/axis2/mtom_test_dl/"> <actionMapping>http://schemas.xmlsoap.org/wsdl/MTOMTestDlServicePortType/MTOMTestDlRequest</actionMapping> <outputActionMapping>//schemas.xmlsoap.org/wsdl/MTOMTestDlServicePortType/MTOMTestDlResponse</outputActionMapping> </operation> <operation name="MTOMTestLs" mep="http://www.w3.org/ns/wsdl/in-out" namespace="http://ws.apache.org/axis2/mtom_test_dl/"> <actionMapping>http://schemas.xmlsoap.org/wsdl/MTOMTestDlServicePortType/MTOMTestLsRequest</actionMapping> <outputActionMapping>//schemas.xmlsoap.org/wsdl/MTOMTestDlServicePortType/MTOMTestLsResponse</outputActionMapping> </operation> </service> </serviceGroup>
ところで、MTOMのパラメータの件は解決したのだが、"MTOMTestDl"がうまく動作
しない。しかも、サーバ側では無くクライアント側で例外が発生する。
なぜだろう。