Skip to main content

Cannot get MTOM to work

31 replies [Last post]
alexanderveit
Offline
Joined: 2005-11-24

Hello,

I'm trying to create a MTOM enabled client and server based on a given SEI (source code attached).

The client seems to communicate well with the server, but if you look on the wire you'll see that the binary data are inlined.

What am I missing here?

The RI's version is JAX-WS RI 2.1.2-b05-RC1.

Regards,
Alex

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
cobaasta
Offline
Joined: 2007-11-21

1. avoid the -Djava.endorsed.dirs parameter respectively use jdk 1.5 instead of jdk 1.6
2. avoid handlers

...and MTOM/XoP works as expected!

steve__t
Offline
Joined: 2010-04-30

> I've tried it using Sun JDK 1.6.0_03 on both Windows
> and Linux. It does not work in both cases. However
> with Sun JDK 1.5.0_10 the data are transfered in
> binary form.
>
> So I still don't know if this is a bug in JAX-WS-RI
> or probably a bad JRE configuration.
>

We recently ran into a similar problem -- our data was being inlined instead of handled as an attachment to the SOAP message. We were using Apache CXF and trying to configure MTOM. We posted the problem over at the cxf-user forum and got a solution from CXF expert Dan Kulp:

http://old.nabble.com/Out-of-memory-when-sending-files-%28MTOM%2C-inlini...

'Hope someone else can benefit from our experience.

Regards,

Steve

daniel_manzke
Offline
Joined: 2007-06-26

I found another posts, where somebody wrote how to get your version.

http://forums.java.net/jive/thread.jspa?threadID=32965&tstart=0

Answering my own post ....

Running 'wsgen -version' gives this answer:

JAX-WS RI 2.0_02-b08-fcs

Maybe give it a try, to fetch your version.

alexanderveit
Offline
Joined: 2005-11-24

> I found another posts, where somebody wrote how to
> get your version.

This is the version that the wsgen tool reports. If you look at the WSDL that's published by the running server, you'll see XML comments that show the JAX-WS version. In my case

rolandm
Offline
Joined: 2007-11-12

Hi,

i found out that if you use an Handler and call inside the
handler

private void logToSystemOut(SOAPMessageContext smc) {
Boolean outboundProperty = (Boolean)
smc.get (MessageContext.MESSAGE_OUTBOUND_PROPERTY);

SOAPMessage mess = smc.getMessage(); !!!!!!!!!!!!!!!!!

the message will always have binary data inlined.

alexanderveit
Offline
Joined: 2005-11-24

There are many network sniffing tool or proxies that you can use. Examples are YATT (http://www.pocketsoap.com/yatt/), TcpTrace (http://www.pocketsoap.com/tcptrace/) or TCPMon (http://ws.apache.org/commons/tcpmon/).

dbranson
Offline
Joined: 2008-01-27

Kindof a delayed response - but as a tcpmon alternative which also does HTTPS you might have a look at my opensource DonsProxy at http://donsproxy.sourceforge.net/.

daniel_manzke
Offline
Joined: 2007-06-26

There could be another fact. How big is your threshold? If your threshold is bigger than the data which should be optimized, he still uses the normal feature. Is it bigger or equal than mtom is used. You can set the threshold on the client side with something like new MTOMFeature(0) and on the server side just use @MTOM(threshold=0).

Greets,
Daniel

alexanderveit
Offline
Joined: 2005-11-24

The threshold was 1. Setting @MTOM(threshold = 0, enabled = true) on the service implementation class and initializing the client service with the new MTOMFeature(0) has no effect.

vivekp
Offline
Joined: 2003-06-10

Can you try the latest JAX-WS RI, JAX-WS RI 2.1.3 nightly from https://jax-ws.dev.java.net/servlets/ProjectDocumentList?folderID=6020&e...

or get 2.1.2 final version.

alexanderveit
Offline
Joined: 2005-11-24

> Can you try the latest JAX-WS RI, JAX-WS RI 2.1.3
> nightly from
> https://jax-ws.dev.java.net/servlets/ProjectDocumentLi
> st?folderID=6020&expandFolder=6020&folderID=6020

The results are the same as with the 2.1.2 version.

> or get 2.1.2 final version.

The distribution that I've downloaded from https://jax-ws.dev.java.net/2.1.2/ reports the build version JAX-WS RI 2.1.2-b05-RC1.

I've modified the Ant script in the attached archive so that

# ant compile
# ant server
# ant client

will dump the HTTP traffic directly to the console.

vivekp
Offline
Joined: 2003-06-10

I just tried your sample and I see it working fine with both JAX-WS 2.1.2 and 2.1.3. I used JDK 1.5_12.

[/c/issues/mtom/mtom-sample]
$ant client
Buildfile: build.xml

client:
[java] ---[HTTP request]---
[java] SOAPAction: ""
[java] Content-Type: multipart/related;start=" c7b66a5e5987@example.jaxws.sun.com>";type="application/xop+xml";boundary="uuid:388158
2c-9fc2-4a16-8e87-c7b66a5e5987";start-info="text/xml"
[java] Accept: text/xml, multipart/related, text/html, image/gif, image/jpeg, *;
q=.2, */*; q=.2
[java] --uuid:3881582c-9fc2-4a16-8e87-c7b66a5e5987
[java] Content-Id: sun.com>
[java] Content-Type: application/xop+xml;charset=utf-8;type="text/xml"
[java] Content-Transfer-Encoding: binary
[java]
[java] ns="http://www.w3.org/2004/08/xop/include" href="cid:29b03515-dfd4-4e50-8ab3-cd8ba3c8
adbd@example.jaxws.sun.com"/>


[java] --uuid:3881582c-9fc2-4a16-8e87-c7b66a5e5987
[java] Content-Id: <29b03515-dfd4-4e50-8ab3-cd8ba3c8adbd@example.jaxws.sun.com>
[java] Content-Type: application/octet-stream
[java] Content-Transfer-Encoding: binary
[java]
[java] Duke
[java] --uuid:3881582c-9fc2-4a16-8e87-c7b66a5e5987
[java] Content-Id: <3ff9c377-53dc-4faa-a4ec-dfb410c8f575@example.jaxws.sun.com>
[java] Content-Type: image/jpeg
[java] Content-Transfer-Encoding: binary
[java]
[java] ╪ α ►JFIF ☺☻ ☺ ☺ █ ♠♠

alexanderveit
Offline
Joined: 2005-11-24

> I just tried your sample and I see it working fine
> with both JAX-WS 2.1.2 and 2.1.3. I used JDK 1.5_12.

I've tried it using Sun JDK 1.6.0_03 on both Windows and Linux. It does not work in both cases. However with Sun JDK 1.5.0_10 the data are transfered in binary form.

So I still don't know if this is a bug in JAX-WS-RI or probably a bad JRE configuration.

These are the files in my jdk1.6.0_03\jre\lib\endorsed directory:
62.983 activation.jar
291.084 FastInfoset.jar
81.798 http.jar
89.967 jaxb-api.jar
847.332 jaxb-impl.jar
3.124.246 jaxb-xjc.jar
36.168 jaxws-api.jar
1.124.303 jaxws-rt.jar
500.286 jaxws-tools.jar
23.346 jsr173_api.jar
7.989 jsr181-api.jar
6.165 jsr250-api.jar
68.177 resolver.jar
18.770 saaj-api.jar
276.614 saaj-impl.jar
331.011 sjsxp.jar
10.370 stax-ex.jar
57.853 streambuffer.jar

These jars (as well as jre\lib\rt.jar and jre\lib\resources.jar) are being loaded by the Java-VM process after a call to the web service.

daniel_manzke
Offline
Joined: 2007-06-26

It looks like a bad JRE configuration. ;) I know when I install a jdk he mostly installs a JRE in the jdk directory and a public JRE. What I mean is, that he maybe uses another place.
Because your desciptions looks like he is using an old JAX-WS which is shipped with the Java 6.

Most times I use a Tomcat to test my webservice. Than I just deploy all files in the WEB-INF/lib folder and there should be no problem with shipped jdk's or endorsed folders.

Daniel

alexanderveit
Offline
Joined: 2005-11-24

> It looks like a bad JRE configuration. ;) I know when
> I install a jdk he mostly installs a JRE in the jdk
> directory and a public JRE. What I mean is, that he
> maybe uses another place.
> Because your desciptions looks like he is using an
> old JAX-WS which is shipped with the Java 6.

All executables and DLLs are loaded from the correct directory. As mentioned above, all jars are loaded from the expected directories, too. So a possible misconfiguration may be more subtle. E.g. too many jars in the endorsed directory, ...

I hope that someone could confirm my odd results :)

dwisler
Offline
Joined: 2007-11-01

Hello,

I am testing MTOM also. I am sending 100MB files and "assuming" that it's using MTOM since I have it all set up properly and started with the "mtom" sample that comes with the metro download. But I'm not positive that it's not inlining the data. I was using Axis2 before and had a SOAP monitor so that I could see the messages. I am curious as to how you are able to get see your SOAP requests in this case. Can you tell me what tool you are using to do this? I would like to make sure that I am truly using MTOM in my test.

Thank you

jitu
Offline
Joined: 2003-06-14
dwisler
Offline
Joined: 2007-11-01

That worked. Thank you very much.

carstensis
Offline
Joined: 2008-01-23

Is there any news when this issue (MTOM with JDK6) is going to be solved? Is it with JDK6 Update 11?

This issue is quite important for us and we cannot switch back to JDK5. We're currently using Axis2 for that case and would happily abandon that ;-)

steve__t
Offline
Joined: 2010-04-30

I know this probably won't benefit the author of this plea, given the date difference, but see my post above. It might address the issue if you're seeing the same problem.

Regards,

Steve

hed5meg
Offline
Joined: 2008-01-04

I am having the same problem, has anyone made any headway on this issue. I would really like to be able to use Java 1.6 in my WebService development.

alexanderveit
Offline
Joined: 2005-11-24

I've file a bug report for this issue:
https://jax-ws.dev.java.net/issues/show_bug.cgi?id=489

cobaasta
Offline
Joined: 2007-11-21

Have exactly the same problem: binary data is always inlined.
This is what i get from the server per tcp/ip monitor after switching off any handlers:

--uuid:10bb0687-6495-40fb-ac4e-378f4e1f33fa
Content-Id:
Content-Type: application/xop+xml;charset=utf-8;type="text/xml"
Content-Transfer-Encoding: binary


... base64 encoded data ...

--uuid:10bb0687-6495-40fb-ac4e-378f4e1f33fa--

I am using JAX-WS 2.1.2, Tomcat 6.0.14, JDK 1.6.0 with -Djava.endorsed.dirs=$JAXWS_HOME/lib
And i am using the Spring extension jaxws-spring 1.7

The MTOM is enabled via @MTOM(threshold=0) in the endpoint implementation.

[b]So what (except the handlers) could force the web service to inline the binary data?[/b]

Greetings

jitu
Offline
Joined: 2003-06-14

Is the service starting from wsdl ? If so, does wsdl have both swaref and mtom ?

cobaasta
Offline
Joined: 2007-11-21

its the "from wsdl to java" pattern.
We use "document literal" as soap binding style.
We nowhere mention swaref or mtom in the wsdl!
The only part in the wsdl you can see the attachment, is the element definition with "base64Binary".
The rest is straight forward as in the samples...










minOccurs="1" maxOccurs="1" />






xmime:expectedContentTypes="image/jpeg"/>























vivekp
Offline
Joined: 2003-06-10

Not sure what is going on, it looks simple enough and should just work. Where do you see the binary data is inlined? Is it client->server or server->client or both?

alexanderveit
Offline
Joined: 2005-11-24

Vivek,

The data are being inlined at both sides. Note that the sample takes a Java-only approach. No wsimport, no configuration files.

Here's the client's request message for the echoData operation:

------------------------------------------------------------
POST / HTTP/1.1
SOAPAction: ""
Accept: text/xml, multipart/related, text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Content-Type: multipart/related;start="";type="application/xop+xml";boundary="uuid:abe42eb7-a50a-4581-bb18-190e52be1025";start-info="text/xml"
User-Agent: JAX-WS RI 2.1.2-b05-RC1
Host: localhost:8888
Connection: keep-alive
Content-Length: 2107

--uuid:abe42eb7-a50a-4581-bb18-190e52be1025
Content-Id:
Content-Type: application/xop+xml;charset=utf-8;type="text/xml"
Content-Transfer-Encoding: binary




... base64 encoded data ...


--uuid:abe42eb7-a50a-4581-bb18-190e52be1025--

------------------------------------------------------------

and the server's response...

------------------------------------------------------------
HTTP/1.1 200 OK
Transfer-encoding: chunked
Content-type: multipart/related;start="";type="application/xop+xml";boundary="uuid:94ebf1e6-7eb5-43f1-85f4-2615fc40c5d6";start-info="text/xml"
Date: Wed, 24 Oct 2007 08:20:30 GMT

80c
--uuid:94ebf1e6-7eb5-43f1-85f4-2615fc40c5d6
Content-Id:
Content-Type: application/xop+xml;charset=utf-8;type="text/xml"
Content-Transfer-Encoding: binary




... base64 encoded data ...


2f

--uuid:94ebf1e6-7eb5-43f1-85f4-2615fc40c5d6--
0

------------------------------------------------------------

jitu
Offline
Joined: 2003-06-14

Looks like a bug to me. Did you try with servlet deployment ?

alexanderveit
Offline
Joined: 2005-11-24

I didn't try it with a servlet container because I have not yet learned how to do that ;)

Our production code will not run in a servlet container either.

gmazza
Offline
Joined: 2005-01-14

> I didn't try it with a servlet container because I
> have not yet learned how to do that ;)
>

Did you remember to call setMTOMEnabled(), as shown in the Apache CXF example here[1]?
[1] http://tinyurl.com/3bj2hl

If you want to learn how to do Servlet deployment, this may be of help for you:
http://www.jroller.com/gmazza/date/20071102

(Actually my example above needs slight updating, I think *I* forgot to call setMTOMEnabled()... :( )

HTH,
Glen

alexanderveit
Offline
Joined: 2005-11-24

Thank your for these links.

Same behaviour when I call setMTOMEnabled(true).