I am trying to make a very simple web-service which does the following:
It's upto the client to decode it and convert it to pdf.
So, here are my questions:
I understand we encode files to base64 for transmission via web service, but where and how does MTOM come into the picture there?
Can some one provide me a simple method which uses MTOM and sends the data back. Do we need to specify something in the WSDL too? or a simple String return type would suffice? Why/Why not?
Thanks
I have seen this code. It uses a lot of annotations, I just need a simple java code using MTOM. New to J2EE HERE :)
UPDATE 1
Decent enough explanation here, now I need to understand it from the implementation level. Good info here, but for .Net
UPDATE 2
What should be the return type of the method "createMTOM(int id)"??
You seem to be mixing up implementation and protocol.
The specification for MTOM is here. This page has sample messages.
If you are using a JAX-WS environment, you most assuredly use Annotations
to turn it on. If you are rolling soap messages by hand, you write whatever Java code you need to write to produce it. Essentially, MTOM means that the content of the data move to an attachment, which is a separate MIME part of the message, and is referenced through an xop:Include element with an href to the MIME part.
The schema has to say base64Binary as the element type, but additional attributes give hints as to the interpretation of the bytes: xmime:contentType and xmime:expectedContentType. In my experience, the JAX-B reference implementation has some limitations on the use of these. You can't, for example, get it to automatically convert text back and forth to bytes. In a typical kit like CXF or Glassfish, you put data into a DataHandler and the kit turns it into the attachment.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With