ExplicitTypes.jws Sample

Demonstrates use of the include-java-types attribute of the @jws:parameter-xml and  @jws:return-xml tag to enable correct conversion of Java types contained in Collections.

Concepts Demonstrated by this Sample

Location of Sample Files

This sample is located in the xmlmap folder of the samples WebLogic Workshop project. In the file system the location is:

BEA_HOME\weblogic700\samples\workshop\applications\samples\xmlmap\ExplicitTypes.jws

How to Run the Sample

To run this web service:

  1. Start WebLogic Server in the appropriate domain.

    • On Microsoft Windows systems, from the Start menu navigate to:

    BEA WebLogic Platform 7.0->WebLogic Workshop->WebLogic Workshop Examples->Start Examples Server.

    • On Linux or Solaris systems, run:

    BEA_HOME/weblogic700/samples/workshop/startWebLogic.sh

  2. Launch the service either by opening it in WebLogic Workshop and selecting the Start operation or by entering http://localhost:7001/samples/xmlmap/ExplicitTypes.jws in the address bar of your browser. If WebLogic Server is running in the appropriate domain on this machine, you may click here to run the sample.

  3. Navigate to the Test XML tab of Test View. This sample expects complex types that cannot be encoded in a HTTP-GET request, so the Test Form page cannot be used to invoke the in method.

  4. Invoke the out method. The out method demonstrates use of the include-java-types to control serialization of objects of otherwise unknown type. The object being serialized is an ArrayList, which is declared to contain Objects. Without help, the serialization code would not know how to serialize a generic Object. The include-java-types attribute provides a list of types being serialized, allowing the serialization code to recognize and properly convert the objects. In this case, the ArrayList being serialized contains an array of int and an array of String as its two elements.

  5. Notice that the message returned contains <int> and <String> elements that represent the contents of the arrays.

  6. From the out method's response, copy the XML between (but not including) the <outResult> tags to the clipboard.

  7. Select "Test operations" to return to the page containing all of the web service's methods.

  8. Paste the contents of the clipboard into the text area for the in method as the contents of the <arrayList> tag. The <in> and <arrayList> tags should remain - you should be replacing everything between the <arrayList> and </arrayList> tags.

  9. Invoke the in method. The response is a formatted string that verifies the input data.

Related Topics

Handling and Shaping XML Messages with XML Maps

@jws:parameter-xml Tag

@jws:return-xml Tag

Test View