Sunday, March 20, 2011

JAX-WS with JBoss 6 Day 2 : MTOM

With Java API for XML-Based Web Services (JAX-WS), you can send binary attachments such as images or files along with Web services requests. JAX-WS adds support for optimized transmission of binary data as specified by SOAP Message Transmission Optimization Mechanism (MTOM).

1. Create a class to hold attachment object it can be any type of files:

2. Enable MTOM and change our hello web service as below:

If you are sending an image file , commented codes can be used

3. Rebuilt our web application and deploy to jboss.

4. Generate client classes and copy to your workspace.
wsconsume -k -p http://localhost:8080/iJBossWS/ws/testService?wsdl

5. Write a test case:

6. It depends on your web service that how the file is being used, by now binary file already transferred to web service side.

7. pom.xml is the same as Day 1 example.

No comments: