OutputScriptMap.jws Sample
A web service that demonstrates use of the ECMAScript language extensions for XML to perform XML mapping using procedural code. A Java object returned by a web service method is converted to a different XML structure in the outgoing message. The ECMAScript is in the PersonScript.jsx file.
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\OutputScriptMap.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/OutputScriptMap.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.
Enter values for fname and lname and invoke the Hello method.
The Hello method receives the values using the default mapping (no custom XML map), but returns its result using an XML map specified with the @jws:return-xml tag. The @jws:return-xml tag includes a <xm:use> tag that calls the ConvertPersonToXML ECMAScript function in the PersonScript.jsx file.
The ECMAScript function formats the fields of the Person object into a schema it determines, then returns that XML to the client.
Examine PersonScript.ps and the relationship between the ECMAScript it contains and the method in OutputScriptMap.jws.
Handling and Shaping XML Messages with XML Maps