Java MTOM and MIME: Enhancing Efficiency - Quiz
Total: 61 questions
1. Can SOAP-based web services consume or return binary data?
2. General approaches to handling arbitrary binary data in SOAP-based web services.
3. Describe approach of handling binary data in SOAP-based web services using encoding.
4. Options of SOAP attachments.
5. The downside of sending byte data as attachment.
6. Main purpose of a DIME extension.
7. Drawbacks of SwA approach.
8. What does acronym MTOM mean?
9. What MTOM is used for?
10. Which type of binary data JAX-WS can send within the XML document?
11. Which type of data does MTOM use?
12. Is MTOM optimization enabled by default?
13. Does MTOM send binary data as part of XML document?
14. Should JAX-WS applications configurate the client or the server artifacts to enable MTOM support?
15. Can MTOM be enabled on the endpoints that implement Provider interface?
16. How to enable MTOM for the server?
17. Which element is used in the XML schema for the binary data?
18. What xmime:expectedContentTypes attribute is used for?
19. Parameters of the @MTOM annotation?
20. What @MTOM.enabled is used for?
21. What @MTOM.threshold parameter is used for?
22. Write example where MTOM is enabled on the web service.
Write example where MTOM is enabled on the web service.
@MTOM
@WebService(name = "ExamPortType",
serviceName = "ExamService",
targetNamespace="http://www.examclouds.com")
public class ExamImpl {
@WebMethod
public String exam(byte[] bytes) {
return new String(bytes);
}
}
23. What @BindingType annotation is used for?
24. Which constants does SOAPBinding class define for the value of the @BindingType annotation?
Which constants does SOAPBinding class define for the value of the @BindingType annotation?
SOAP11HTTP_MTOM_BINDING and SOAP12HTTP_MTOM_BINDING for SOAP version 1.1 and SOAP version 1.2 correspondingly.
25. Example of using the Optimized Mime Serialization policy assertion.
Example of using the Optimized Mime Serialization policy assertion.
<wsdl:definitions
targetNamespace="examclouds.com"
xmlns:tns="examclouds.com"
... >
<wsp:Policy wsu:Id="ExamPolicy" >
<wsoma:OptimizedMimeSerialization />
</wsp:Policy>
<wsdl:binding name="ExamBinding" type="tns:ExamPortType" >
<wsp:PolicyReference
URI="#ExamPolicy"
wsdl:required="true" />
</wsdl:binding>
</wsdl:definitions>
26. For which elements an optimization is available?
27. Example of how binding uses the MTOM policy.
Example of how binding uses the MTOM policy.
<binding name="examBinding" type="tns:examPortType">
<wsp:PolicyReference URI="#examBindingPolicy"/>
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="examOperation">
<soap:operation/>
<input name="input1">
<soap:body use="literal" namespace="http://j2ee.netbeans.org/wsdl/mtomBP/mtom"/>
</input>
...
</binding>
28. Example of the SOAP envelope with binary data transmitted as MTOM.
Example of the SOAP envelope with binary data transmitted as MTOM.
<?xml version='1.0' encoding='UTF-8'?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:mtomOperation xmlns:ns2="http://j2ee.netbeans.org/wsdl/mtomBP/mtom">
<part1>English</part1>
<part2>
<xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include"
href="cid:[email protected]" />
</part2>
</ns2:mtomOperation>
</S:Body>
</S:Envelope>
29. Which element in wsdl is used to specify where the binary data is?
Which element in wsdl is used to specify where the binary data is?
A <xop:Include> element.
30. Is MTOM suitable for a large number of tiny attachments?
31. How to enable MTOM on server?
32. What MTOMFeature is used for?
What MTOMFeature is used for?
To specify if MTOM should be used with a web service. The feature is used instead of the SOAPBinding.SOAP11HTTP_MTOM_BINDING,
SOAPBinding.SOAP12HTTP_MTOM_BINDING and
the SOAPBinding.setMTOMEnabled().
33. Properties of the MTOMFeature.
34. What swaRef is used in WSDL for?
35. How to enable MTOM on the client side?
36. Describe how to map wsi:swaRef to DataHandler by JAXB 2.0.
Describe how to map wsi:swaRef to DataHandler by JAXB 2.0.
An application constructs the DataHandler with the data and the appropriate MIME type and JAX-WS coordinates with JAXB and SAAJ to send it as attachment MIME part.
37. Which class does MTOMFeature extend?
38. Example of enabling MTOM on the client.
39. Which parameters does the MTOMFeature constructor accept?
40. Methods of enabling MTOM on a Dispatch client.
41. Example of enabling MTOM on a Dispatch client by using SOAPBinding. setMTOMEnabled().
Example of enabling MTOM on a Dispatch client by using SOAPBinding. setMTOMEnabled().
SOAPBinding binding = (SOAPBinding)dispatch.getBinding();
binding.setMTOMEnabled(true);
42. Example of enabling MTOM on a Dispatch client by using Service.addPort.
Example of enabling MTOM on a Dispatch client by using Service.addPort.
Service svc = Service.create(serviceName);
svc.addPort(portName,SOAPBinding.SOAP11HTTP_MTOM_BINDING,endpointUrl);
43. Example of enabling MTOM on a Dispatch client by using MTOMFeature.
Example of enabling MTOM on a Dispatch client by using MTOMFeature.
MTOMFeature mtomFeature = new MTOMFeature(true, 1024);
Service service = Service.create(serviceName);
service.addPort(portName, SOAPBinding.SOAP11_HTTP_BINDING, endpointUrl);
Dispatch<Source> dsp = service.createDispatch(portName, Source.class, Service.Mode.PAYLOAD, mtomFeature);
44. Example of enabling MTOM on a Dynamic Proxy client.
45. Example of enabling MTOM on the client using the @MTOM annotation.
Example of enabling MTOM on the client using the @MTOM annotation.
public class ClientApplication {
@MTOM(enabled = true, threshold = 1024)
@WebServiceRef(ExamService.class)
private ExamPortType examPort;
...
}
46. Example of enabling MTOM on the client using deployment descriptor elements within a port-component-ref element.
Example of enabling MTOM on the client using deployment descriptor elements within a port-component-ref element.
<service-ref>
<service-ref-name>service/ExamPortComponentRef</service-ref-name>
<service-interface>com.examclouds.ExamService</service-ref-interface>
<port-component-ref>
<service-endpoint-interface>com.examclouds.ExamPortType</service-endpoint-interface>
<enable-mtom>true</enable-mtom>
<mtom-threshold>1024</mtom-threshold>
</port-component-ref>
</service-ref>
47. Scopes of properties for MessageContext.
48. Are all properties available to all handlers for an instance of a MEP on a particular endpoint?
49. If a logical handler sets a property in the message context, where that property will be available?
50. Where APPLICATION scoped properties are available?
51. The default property's scope?
52. Example of standard message context properties.
Example of standard message context properties.
- javax.xml.ws.binding.attachments.inbound
- javax.xml.ws.binding.attachments.outbound
53. Type of javax.xml.ws.binding. attachments.inbound and javax.xml.ws.binding. attachments.outbound.
Type of javax.xml.ws.binding. attachments.inbound and javax.xml.ws.binding. attachments.outbound.
Map<String, DataHandler>
54. What are the key and the value of javax.xml.ws. binding.attachments.inbound and javax.xml.ws. binding.attachments.outbound properties?
What are the key and the value of javax.xml.ws. binding.attachments.inbound and javax.xml.ws. binding.attachments.outbound properties?
The key is an unique identifier for the attachment. The value is a DataHandler for the attachment data.
55. Specified constants for javax.xml.ws.binding. attachments.inbound and javax.xml.ws.binding. attachments.outbound properties of MessageContext.
Specified constants for javax.xml.ws.binding. attachments.inbound and javax.xml.ws.binding. attachments.outbound properties of MessageContext.
OUTBOUND_MESSAGE_ATTACHMENTS,
INBOUND_MESSAGE_ATTACHMENTS.
56. Where Mime attachments, specified by the javax.xml.ws.binding. attachments.inbound and javax.xml.ws.binding. attachments.outbound properties can be changed?
Where Mime attachments, specified by the javax.xml.ws.binding. attachments.inbound and javax.xml.ws.binding. attachments.outbound properties can be changed?
In logical handlers.
57. Does any changes to the javax.xml.ws.binding. attachments.inbound and javax.xml.ws.binding. attachments.outbound properties applicable after calling the first SOAPHandler?
Does any changes to the javax.xml.ws.binding. attachments.inbound and javax.xml.ws.binding. attachments.outbound properties applicable after calling the first SOAPHandler?
No, they are ignored.
58. Can the SOAPHandler modify the properties in the MessageContext?
59. Will attachments, specified by the javax.xml.ws.binding. attachments.outbound property, be included as mime attachments in the message, when using Dispatch in SOAP / HTTP binding in payload mode?
Will attachments, specified by the javax.xml.ws.binding. attachments.outbound property, be included as mime attachments in the message, when using Dispatch in SOAP / HTTP binding in payload mode?
Yes.
60. Will the javax.xml.ws.binding. attachments.outbound property be applied when using Dispatch in SOAP / HTTP binding in message mode?
Will the javax.xml.ws.binding. attachments.outbound property be applied when using Dispatch in SOAP / HTTP binding in message mode?
No.
61. Example of setting properties to Dispatch client.
Example of setting properties to Dispatch client.
Dispatch<String> d = s.createDispatch(portName, String.class, Service.Mode.PAYLOAD);
Map<String, Object> requestContext = d.getRequestContext();
Map<String, DataHandler> attachments = new HashMap();
attachments.put("examCID", examDataHandler);
requestContext.put("javax.xml.ws.binding.attachments.outbound", attachments);