1

I am just getting started with SOAP web services and stumbled across MTOM.

I need to know 2 things based on following use case: A user will call a SOAP web service by passing an image. In response, they will get a formatted version of the same image.

  1. I know that I need to setMTOMEnabled(true) in client but do I have to mention it in service also. Also when the WSDL is generated how can I tell that this service uses MTOM?
  2. When client sends binary data then MTOM has to be mentioned in client code but if client sends textual data and server sends binary data then does the client also have to use MTOM?
JGlass
  • 1,427
  • 2
  • 12
  • 26
ofortuna
  • 187
  • 2
  • 17
  • We meet again ;-) This will get you started with a couple of your questions though not all [How does mtom work](https://stackoverflow.com/questions/215741/how-does-mtom-work) – JGlass Jan 31 '18 at 18:48
  • Some of these [MTOM results](https://stackoverflow.com/search?q=MTOM) I think they'll also answer many of your questions. – JGlass Jan 31 '18 at 18:50
  • great points but still i have my those 2 questions – ofortuna Jan 31 '18 at 18:53
  • Updated, let me know if it helps! – JGlass Jan 31 '18 at 19:44

1 Answers1

1

I'll elaborate further as I gather more information and update this answer but on question one "JAX-WS applications require separate configuration of both the client and the server artifacts to enable MTOM support" and "the WSDL file includes a xsd:base64Binary or xsd:hexBinary element definition for the binary data." and also it may contain "xmime:expectedContentTypes"

On two, I believe this answers your question "JAX-WS applications require separate configuration of both the client and the server artifacts to enable MTOM support"

But again, still checking around for you.

More of an example of what you'd see in the WSDL

<xs:complexType name="ImageDepot">
    <xs:sequence>
        <xs:element name="imageData" type="xs:base64Binary" xmime:expectedContentTypes="image/jpeg"/>
    </xs:sequence>
</xs:complexType>
........
</types

Mapping of MIME type and Java type. Describes the mapping between MIME types and Java types.

MIME Type Java Type

image/gif - java.awt.Image

image/jpeg - java.awt.Image

text/plain - java.lang.String

text/xml - javax.xml.transform.Source

application/xml javax.xml.transform.Source

/ javax.activation.DataHandler

So on your second question I believe it was the text would just still be considered an attachment but would have the type of text/plain

Community
  • 1
  • 1
JGlass
  • 1,427
  • 2
  • 12
  • 26