Testing and monitoring the MTOM enabled Web service
Now it is time to see if MTOM really optimizes the transmission of the data:
| The output folder is C:\7672code\webservice\mtomresult. We use this folder to store the document received by the Web service JavaBean.
|
| In the sample JSP client, select the sendImage method.
|
| Click Browse and navigate to C:\7672code\webservice\mtom. Select BlueHills.jpg and click Open.
|
Figure 18-45 Invoking the MTOM Web service sendImage method
| In the Result pane, click View image. The image is displayed in the Results pane.
|
| Examine the C:\7672code\webservice\mtomresult folder. You can see that BlueHills.jpg is stored in this folder. Note that the size is different from the same file in the mtom folder (probably a different JPEG compression is used).
|
| Select the TCP/IP Monitor tab to view the SOAP traffic. Click the icon and then select Show Header. The HTTP header and the SOAP traffic are shown in Figure | 8-46.
|
Figure 18-46 SOAP traffic when MTOM is only enabled for the Web service
| Take a look at the SOAP request and response:
|
The Web service (provider) has MTOM enabled after the code generation. Therefore, the SOAP response has a smaller payload! The Web service sends the binary data as a MIME attachment outside the XML document to realize the optimization.
|
The SOAP request has a much larger payload because MTOM is not enabled. The Web service client sends binary data as base64 encoded data within the XML document.
|
Example 18-24 SOAP response message and HTTP header with MTOM enabled
HTTP/1.1 200 OK
Content-Type: multipart/related;
boundary=MIMEBoundaryurn_uuid_2CA974D954B67CAB601228439267478;
type="application/xop+xml";
start="<0.urn:uuid:2CA974D954B67CAB601228439267479@apache.org>";
start-info="text/xml"
Content-Language: en-US
Content-Length: 29635
Date: Fri, 05 Dec 2008 01:07:32 GMT
Server: WebSphere Application Server/7.0
==========================================================================
--MIMEBoundaryurn_uuid_7EF64465327292D3521225396635214
Content-Type: application/xop+xml; charset=UTF-8; type="text/xml"
Content-Transfer-Encoding: binary
Content-ID: <0.urn:uuid:2CA974D954B67CAB601228439267479@apache.org>
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<ns2:sendImageResponse xmlns:ns2="http://mtom.rad75.ibm.com/">
<return>
<xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include"
href="cid:urn:uuid:2CA974D.....@apache.org"/>
</return>
</ns2:sendImageResponse>
</soapenv:Body>
</soapenv:Envelope>
--MIMEBoundaryurn_uuid_2CA974D954B67CAB6012284392674784
Content-Type: image/jpeg
Content-Transfer-Encoding: binary
Content-ID: <urn:uuid:2CA974D954B67CAB601228439267605@apache.org>
ÿØÿà
The type and content-type attributes have the value application/xop+xml, which indicates that the message was successfully optimized using XML-binary Optimized packaging (XOP) when MTOM was enabled.