aspose file tools
The moose likes Web Services and the fly likes JAX-WS MTOM is not workink as expected. Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Web Services
Reply Bookmark "JAX-WS MTOM is not workink as expected." Watch "JAX-WS MTOM is not workink as expected." New topic
Author

JAX-WS MTOM is not workink as expected.

Sagar Lakade
Greenhorn

Joined: Apr 08, 2010
Posts: 3
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

Joined: Jul 09, 2001
Posts: 1121
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


William Butler Yeats: All life is a preparation for something that probably will never happen. Unless you make it happen.
Sagar Lakade
Greenhorn

Joined: Apr 08, 2010
Posts: 3
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

Joined: Apr 08, 2010
Posts: 3
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
Bartender

Joined: Oct 04, 2006
Posts: 2193
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!
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: JAX-WS MTOM is not workink as expected.
 
Similar Threads
Consuming binary data from webservice.
MTOM not working in Axis2
How to determine if it is Document style or RPC looking at SOAP request ?
SOAP with Attachment. and WSDL
Cannot find dispatch method for {http://www.ivan.com/additionservicetypes}addValuesRequest