# SimpleMap.jws Sample

This topic inludes the source code for the SimpleMap.jws Sample.

## Sample Location

This sample is located in the following directory in your WebLogic Workshop installation:

BEA_HOME/weblogic81/samples/workshop/SamplesApp/WebServices/xqueryMap/

## Sample Source Code

`01 package xqueryMap; 02 03 /** 04 * A web service to illustrate a simple parameter-XML map that uses XQuery. 05 * 06 * @common:xmlns namespace="http://openuri.org/bea/samples/workshop/xmlmap/simpleMap" prefix="ns0" 07 * @common:target-namespace namespace="http://workshop.bea.com/SimpleMap" 08 */ 09 public class SimpleMap implements com.bea.jws.WebService 10 { 11 /** 12 * This method uses a simple XQuery map to ensure that the parameter values in 13 * the incoming XML message are correctly mapped to the parameters themselves. 14 * The map itself (with its acceptPerson root element) reflects the method's 15 * default XML schema -- a kind of default template for what an incoming message 16 * should look like. However, the actual incoming message will be different; for 17 * example, its root element is person, rather than acceptPerson.<br/><br/> 18 * 19 * To test this method, use the Test XML page in Test View. Looking at the 20 * XML in the box provided there, replace the lastName and firstName values 21 * with names of your own. Click acceptPerson to see the results of the test.<br/><br/> 22 * 23 * The XQuery code in the map's curly braces retrieves values from 24 * the actual incoming XML message. Here, $input stands for the incoming 25 * message's top element. What follows after it is a path to the part of the 26 * XML whose value should be inserted where the XQuery expression is.<br/><br/> 27 * 28 * For the schema that defines the incoming message, see SimpleMap.xsd in the 29 * Schemas project of the SamplesApp application. 30 * <br/> 31 * 32 * @common:operation 33 * @jws:parameter-xml xquery:: 34 * declare namespace ns0 = "http://openuri.org/bea/samples/workshop/xmlmap/simpleMap" 35 * declare namespace ns1 = "http://workshop.bea.com/SimpleMap" 36 * 37 * <ns1:acceptPerson> 38 * <ns1:lastName>{ data($input/ns0:lastname) }</ns1:lastName> 39 * <ns1:firstName>{ data($input/ns0:firstname) }</ns1:firstName> 40 * </ns1:acceptPerson> 41 * :: 42 * schema-element="ns0:person" 43 */ 44 public String acceptPerson(String lastName, String firstName) 45 { 46 System.out.println(lastName + firstName); 47 lastName = lastName.trim(); 48 firstName = firstName.trim(); 49 return ("Received person: '" + firstName + " " + lastName + "'"); 50 } 51 }`