Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JAX-WS MTOM is not workink as expected.

 
Sagar Lakade
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is my test code
------------------------------------------------------------------------------------------------

import javax.activation.DataHandler;
import javax.activation.FileDataSource;
import javax.jws.WebService;
import javax.xml.ws.BindingType;
import javax.xml.ws.soap.MTOM;

/**
*
* @author sagar.lakade
*/
@MTOM(threshold = 1, enabled = true )
@BindingType(value=javax.xml.ws.soap.SOAPBinding.SOAP11HTTP_BINDING)
@WebService()
public class AttachService {


public DataHandler getFile(String id) {
FileDataSource fileSource = new FileDataSource("C:\\realtek.log");
return new DataHandler(fileSource);
}




response of web service I got In SOAPUI
-----------------------------------------------------------------------------------------------------------------------------------------
HTTP/1.1 200 OK
X-Powered-By: Servlet/2.5
Server: GlassFish/v3
Content-Type: multipart/related;start="<rootpart*677e28d1-4ba9-4edb-a7ed-7deab5867df0@example.jaxws.sun.com>";type="application/xop+xml";boundary="uuid:677e28d1-4ba9-4edb-a7ed-7deab5867df0";start-info="text/xml"
Transfer-Encoding: chunked
Date: Thu, 08 Apr 2010 13:00:39 GMT

--uuid:677e28d1-4ba9-4edb-a7ed-7deab5867df0
Content-Id: <rootpart*677e28d1-4ba9-4edb-a7ed-7deab5867df0@example.jaxws.sun.com>
Content-Type: application/xop+xml;charset=utf-8;type="text/xml"
Content-Transfer-Encoding: binary

<?xml version='1.0' encoding='UTF-8'?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><ns2:getFileResponse xmlns:ns2="http://srvc/"><return>W0luc3RhbGxTaGllbGQgU2lsZW50XQ0KVmVyc2lvbj12Ny4wMA0KRmlsZT1Mb2cgRmlsZQ0KW1Jlc3BvbnNlUmVzdWx0XQ0KUmVzdWx0Q29kZT0wDQpbQXBwbGljYXRpb25dDQpOYW1lPVJlYWx0ZWsgSGlnaCBEZWZpbml0aW9uIEF1ZGlvIERyaXZlcg0KVmVyc2lvbj0yLjMzDQpDb21wYW55PVJlYWx0ZWsgU2VtaWNvbmR1Y3RvciBDb3JwLg0KTGFuZz0wMDA5DQo=</return></ns2:getFileResponse></S:Body></S:Envelope>
--uuid:677e28d1-4ba9-4edb-a7ed-7deab5867df0--


-------------------------------------------------------------------------------------------------------------------------
from above response , we can see that response is inline and not as attachment.
What should be the changes in service provider class so that I get desired result.


 
Dan Drillich
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sagar,

Apparently you need to decrease the value of @MTOM threshold to 0.

Enabling MTOM for JAX-WS Web services says -
The threshold parameter has an integer value, and it specifies the minimum size for messages that are sent using MTOM. When the message size is less than this specified integer, the message is inlined in the XML document as base64 or hexBinary data.


Regards,
Dan
 
Sagar Lakade
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Dan,

Thanks you for the response. I have made the changes - @MTOM( threshold = 0, enabled = true ) in service provider class.
But still not getting desired result.

I have searched for this issue on net, some of the these blogs say that it is related to MTOM and jdk1.6 . They also suggest to copy webserservice related jar files to endorsed directory .

I am using following version of netbeans :

Product Version: NetBeans IDE 6.7.1 (Build 200911211148)
Java: 1.6.0_07; Java HotSpot(TM) Client VM 10.0-b23
System: Windows XP version 5.1 running on x86; Cp1252; en_US (nb)
Userdir: C:\Documents and Settings\sagar.lakade\.netbeans\6.7


Is it the real cause in may case? I will try this code with jdk 1.5 and post my findings.

Please comment.

Regards,
Sagar


 
Sagar Lakade
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Even with following combination not getting desired result

Product Version: NetBeans IDE 6.7.1 (Build 200907230233)
Java: 1.5.0_08; Java HotSpot(TM) Client VM 1.5.0_08-b03
System: Windows XP version 5.1 running on x86; Cp1252; en_US (nb)
Userdir: C:\Documents and Settings\Administrator\.netbeans\6.7
 
Ivan Krizsan
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
I don't know if it is of interest to you, but I have written a tutorial on developing a SOAP web service with MTOM.
You can find it on page 361 in this document: http://www.slideshare.net/krizsan/scdjws-5-study-notes-3085287
If you choose to work through the tutorial and there are problems, please let me know!
Best wishes!
 
Binu George
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If an attachment is smaller than the size specified in threshold parameter, the runtime will inline the binary data as base64 binary instead of creating an attachment.
Check your threshold configuration and size of attachment. May be helpful. JAX-WS Attachment – Enable MTOM for JAX-WS Web services
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic