} }
Files Prepare Run Troubleshooting Related Topics
This example shows how to create a Web Service using the MTOM encoding and write a standalone Java client application that invokes operations of the Web Service.
MTOM is the W3C Message Transmission Optimization Mechanism, a method of efficiently sending binary data between Web Services. It uses XOP (XML-binary Optimized Packaging) to transmit this binary data. WebLogic Web Services use WS-Policy file to enable MTOM encoding. This example uses the pre-packaged policy file - Mtom.xml.
As described in the Web Service example Creating a Web Service Using JWS Metadata Annotations (listed under the Oracle WebLogic Server Examples > Examples > API> Web Services node in the Samples Viewer), this example uses also JWS annotations to specify the shape and behavior of the Web Service. See the documentation for the simple Web Service example for a full explanation of the basic JWS annotations (@WebService, @WebMethod, @SoapBinding, and @WLHttpTransport). This example describes additional JWS annotations used to create a MTOM encoding enabled Web Service.
The generated Web Service in this example, called SecureHelloWorldService, has a single operation: sayHello that simply returns the inputted String parameter.
The MtomService.java Java source file (also called JWS file) forms the basis of the Web Service. The file uses both standard (defined by the Web Services Metadata for the Java Platform specification, or JSR-181) and WebLogic-specific JWS annotations to define the shape and behavior of the Web Service.
In addition to the basic JWS annotations, the JWS file uses the following additional ones:
The MtomClient.java file is the standalone client application that invokes the MtomService MTOM encoding enabled Web Service. As usual, it uses the JAX-RPC stubs generated by the clientgen Ant task to create a Service instance and get the portType from which the operations of the Web Service can be invoked.
Directory Location:
MW_HOME/wlserver_10.3/samples/server/examples/src/examples/webservices/mtom/
(where MW_HOME is the directory containing your Oracle WebLogic Server installation)
File Click source files to view code. |
Description |
---|---|
MtomService.java | JWS file that implements the MTOM Web Service. The JWS file uses the @Policy annotation to specify the WS-Policy files that are associated with the Web Service. In this example, the @Policy annotation points to the pre-packaged WS-Policy file Mtom.xml which enables MTOM encoding. |
MtomClient.java | Standalone client application that invokes the MTOM Web Service. Uses the JAX-RPC Stubs generated by clientgen, based on the WSDL of the Web Service. |
build.xml | Ant build file that contains targets for building and running the example. |
Before working with this example:
There are no server configurations for this example.
To run the example, follow these steps:
prompt> ant run
http://host:port/MtomService/MtomService?WSDL
Where:
If your example runs successfully, you will get output similar to the following message in the command shell from which you ran the client application:
Buildfile: build.xml
run:
[java] sending a String 'FOO' as a byte array.
[java] echoing 'FOO' as a String.
[java] sending a String 'FOO'
[java] echoing 'FOO' as a byte array.
[java] sending a String 'FOO' as a byte array.
[java] echoing 'FOO' as a String array.BUILD SUCCESSFUL
(Internet connection required.)