} }

 Files   Prepare   Run   Troubleshooting   Related Topics 

 

About the Example

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.

 

Overview of MTOM Encoding

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.

 

Description of the MTOM encoding enabled Web Service

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:

 

Description of the Client Application That Invokes the Web Service

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.


 

Files Used in the Example

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.

 

Prepare the Example

 

Prerequisites

Before working with this example:

  1. Install Oracle WebLogic Server, including the examples.
  2. Start the Examples server.
  3. Set up your environment.

 

Configure Oracle WebLogic Server

There are no server configurations for this example.

 

Build and Deploy the Example

  1. Change to the SAMPLES_HOME\server\examples\src\examples\webservices\mtom directory, where SAMPLES_HOME refers to the main Oracle WebLogic Server examples directory, such as d:\Oracle\Middleware\wlserver_10.3\samples.
  2. Execute the following command:

    prompt> ant build

    This command compiles and stages the example.
  3. Execute the following command:

    prompt> ant deploy

    This command deploys the example on the wl_server domain of your Oracle WebLogic Server installation.

 

Run the Example

To run the example, follow these steps:

  1. Complete the steps in the "Prepare the Example" section.
  2. In your development shell, run the MtomClient.java Java application by running the following command from the main example directory (SAMPLES_HOME\server\examples\src\examples\webservices\mtom):

    prompt> ant run

  3. After building and running the example, you can view the WSDL of the Web Service by typing the following URL in your Web browser:

    http://host:port/MtomService/MtomService?WSDL

    Where:

 

Check the Output

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


 

Troubleshooting


 

Related Topics

(Internet connection required.)