ConsolidateAddress.jws Sample

A web service that demonstrates use of the ECMAScript language extensions for XML to perform XML mapping using procedural code. An incoming XML document is converted to a different internal Java data structure, then converted back when returned to the client by a subsequent method call. The ECMAScript is in the ConsolidateAddressScript.jsx file. ConsolidateTest.xml is a test document that may be submitted.

# Concepts Demonstrated by this Sample

- Use of the JwsContext interface

- Use of Conversations

- XML maps

- XML maps with ECMAScript

# 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\ConsolidateAddress.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/ConsolidateAddress.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 Form tab of Test View, if necessary.

4. Open ConsolidateTest.xml in WebLogic Workshop or a text editor. Copy the contents and paste them into the text box for the setEmployees method between the <employees> and </employees> XML tags.

5. Invoke setEmployees. The XML document submitted is processed by the XML parameter map on the setEmployees method. The paramater map in turn invokes the ECMAScript function ConsolidateAddressScriptFromXML via the <xm:use> tag in the parameter map. The ConsolidateAddressScriptFromXML processes the incoming XML document and transfers data from it to the Java types that are native to the web service.

6. Click on the conversation ID (the large number at the top each conversation in the Message Log) to access that conversation's continue and finish methods.

7. Invoke getEmployeesNatural. This method returns the internal data structure directly, without an XML map. WebLogic Workshop provides a natural mapping that is used by default when compound objects require conversion to XML. The response to the method invocation is the natural mapping of the internal Java data structure in which the data is stored. Notice that the internal structure is different from the structure of the document you passed in to setEmployees.

8. Click on the conversation ID again to return to the conversation's continue and finish methods.

9. Invoke getEmployees. This method, like setEmployees, uses an XML map with ECMAScript to convert the Java objects returned by the method to XML. The ECMAScript method ConsolidateAddressScriptToXML is used in this case. It converts the Java structure back into the format that the input document had.

10. Examine ConsolidateAddressScript.ps and the relationship between the ECMAScript it contains and the methods in ConsolidateAddress.jws.

Related Topics

Maintaining State with Conversations

JwsContext Interface

Handling and Shaping XML Messages with XML Maps

Handling XML with ECMAScript Extensions

<xm:use> Tag

@jws:parameter-xml Tag

@jws:return-xml Tag

OutputScriptMap.jws Sample

Test View