Home
Enabling MTOM on the client
Now let us enable MTOM on the client side as well:
![]()
In the Enterprise Explorer expand RAD7MTOMClient Æ Java Resources Æ src Æ com.ibm.rad75.mtom and open ProcessDocumentPortProxy.java.
![]()
Add one lines of code to each business method to invoke a new enableMTOMClient method (Example | 8-25). Refer to C:\7672code\webservice\mtom\ProcessDocumentPortProxy.java. Example 18-25 Enable MTOM on the client
import javax.xml.ws.soap.SOAPBinding;public class ProcessDocumentPortProxy{......public byte[] sendWordFile(byte[] arg0) {enableMTOMClient();return _getDescriptor().getProxy().sendWordFile(arg0);}public Image sendImage(Image arg0) {enableMTOMClient();return _getDescriptor().getProxy().sendImage(arg0);}public DataHandler sendPDFFile(DataHandler arg0) {enableMTOMClient();return _getDescriptor().getProxy().sendPDFFile(arg0);}private void enableMTOMClient(){SOAPBinding binding = (SOAPBinding)((BindingProvider)_getDescriptor().getProxy()).getBinding();binding.setMTOMEnabled(true);}}
![]()
![]()
Run the sample JSP again using the sendImage method and the ...\mtom\BlueHills.jpg file. The SOAP request also has a small payload after MTOM is enabled for the Web service client (Figure | 8-47).
![]()
In the sample JSP client, invoke the sendWordFile method. Click Browse to locate the word document ...\mtom\RAD-intro.doc, and click Invoke. Watch the SOAP traffic in the TCP/IP Monitor.
![]()
Invoke the sendPDFFile method. Click Browse to locate the PDF document ...\mtom\JAX-WS.pdf, and click Invoke. Watch the SOAP traffic in the TCP/IP Monitor.
![]()
Verify the C:\7672code\webservice\mtomresult folder. We can see that the image file, word document, and PDF file are all stored successfully.
![]()
Figure 18-47 SOAP message with MTOM enabled for both client and server
ibm.com/redbooks