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.
Use of the JwsContext interface
Use of Conversations
XML maps
XML maps with ECMAScript
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
To run this web service:
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
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.
Navigate to the Test Form tab of Test View, if necessary.
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.
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.
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.
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.
Click on the conversation ID again to return to the conversation's continue and finish methods.
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.
Examine ConsolidateAddressScript.ps and the relationship between the ECMAScript it contains and the methods in ConsolidateAddress.jws.
Maintaining State with Conversations
Handling and Shaping XML Messages with XML Maps