uCosminexus Application Server, Web Service Development Guide
The availability of attachments in MTOM/XOP specification format in the Web Service client side JAX-WS engine depends upon the MTOMFeature class used to obtain an SEI. The following table describes the availability of attachments in MTOM/XOP specification format, and the behavior upon sending/receiving the messages.
Table 30-4 Availability of attachments in MTOM/XOP specification format and the behavior upon sending/receiving the messages
| No. | Attachment in MTOM/XOP specification format | Relation between the threshold and the size of the attachment to be sent# | Data included in the request messages to be sent | Data included in the received response messages | Successfully received/failed |
|---|---|---|---|---|---|
| 1 | Used | Threshold |
Binary data | Binary data | Successful |
| 2 | Base64 type data | Successful | |||
| 3 | Threshold>attachment size | Base64 type data | Binary data | Successful | |
| 4 | Base64 type data | Successful | |||
| 5 | Not used | -- | Base64 type data | Binary data | Successful |
| 6 | Base64 type data | Successful |
The MTOMFeature class can be used concurrently with the other Feature classes. The following is one such example:
package com.sample;
......
public class TestClient {
public static void main(String[] args) {
try {
File portrait = new File("portrait.png");
if (!portrait.exists() ) {
throw new RuntimeException("Cannot file \"portrait.png\".");
}
BufferedImage image = ImageIO.read(portrait);
AddressingFeature addressingFeature = new AddressingFeature();
MTOMFeature mtomFeature = new MTOMFeature();
UserInfoService service = new UserInfoService();
UserInfoImpl port = service.getUserInfoImplPort(addressingFeature, mtomFeature);
UserData userData = port.getUserData(image);
......
} catch (Exception e) {
e.printStackTrace();
}
}
}
|
You can set the availability of attachments in MTOM/XOP specification format by using the setMTOMEnabled method of javax.xml.ws.soap.SOAPBinding instead of the MTOMFeature class. The following example describes how to set the availability of attachments in MTOM/XOP specification format by using the setMTOMEnabled method of javax.xml.ws.soap.SOAPBinding:
package com.sample;
......
public class TestClient {
public static void main(String[] args) {
try {
File portrait = new File("portrait.png");
if (!portrait.exists() ) {
throw new RuntimeException("Cannot file \"portrait.png\".");
}
BufferedImage image = ImageIO.read(portrait);
UserInfoService service = new UserInfoService();
UserInfoImpl port = service.getUserInfoImplPort();
BindingProvider bindingProvider = (BindingProvider)port;
Binding binding = bindingProvider.getBinding();
SOAPBinding soapBinding = (SOAPBinding)binding;
soapBinding.setMTOMEnabled(true);
UserData userData = port.getUserData(image);
......
} catch (Exception e) {
e.printStackTrace();
}
}
}
|
When setting up the availability of attachments in MTOM/XOP specification format by using the setMTOMEnabled method of javax.xml.ws.soap.SOAPBinding, if the availability is already set up by the setMTOMEnabled method of the javax.xml.ws.soap.SOAPBinding and the MTOMFeature class beforehand, the values that are set up later by the setMTOMEnabled method become invalid and the availability cannot be set.
If you do not use the MTOMFeature class when obtaining an SEI, or if you do not set the availability of attachments in MTOM/XOP specification format in the setMTOMEnabled method of javax.xml.ws.soap.SOAPBinding, the attachments in MTOM/XOP specification format are not used. The request messages sent will include Base64 type data. Also, irrespective of whether the messages include binary data, all response messages are received.
Depending upon the availability of the xmime:expectedContentTypes attribute in the WSDL schema element, the Content-Type field value present in the attachment part of the messages sent by the attachments in MTOM/XOP specification format changes. See below for how the Content-Type value in the attachment part changes depending upon whether the xmime:expectedContentTypes attribute is used.
All Rights Reserved. Copyright (C) 2013, Hitachi, Ltd.