Specifies the variable to use when mapping an XML attribute value.
<xm:attribute name="attributeName" obj="[dataType ]attributeValueVariable[, …]" >
name
The name of the attribute that is being mapped.
obj
The portion of the Java declaration to which this attribute's value should be mapped, such as a parameter or "return".
Use the <xm:attribute> tag to assign an attribute value from an XML message to a portion of your Java declaration. In the following example, max_records is an anticipated attribute of the <query> element:
/** * @common:operation * @jws:parameter-xml xml-map:: * <query> * <xm:attribute name="max_records" obj="resultSize"/> * <element> * <name>{criterionName}</name> * <value>{criterionValue}</value> * </element> * </query> * :: */ public void searchData(String criterionName, String criterionValue, int resultSize) { System.out.println("The maximum number of records to return is " + resultSize); }
As an alternative to using the <xm:attribute> tag, you can use curly braces shorthand. The following snippet is equivalent to the preceding example:
/** * @jws:parameter-xml xml-map:: * <query max_records="{resultSize}"> * <element> * <name>{criterionName}</name> * <value>{criterionValue}</value> * </element> * </query> * :: */ public void searchData(String criterionName, String criterionValue, int resultSize) { System.out.println("The maximum number of records to return is " + resultSize); }
Specify a data type when the variable is not declared with a type elsewhere in the map's context (such as elsewhere in the map, in Java code at the class level, or in the code for the method to which the map applies).
/** * @jws:parameter-xml xml-map:: * <query max_records="{int resultSize}"> * <element> * <name>{java.sql.String criterionName}</name> * <value>{java.sql.String criterionValue}</value> * </element> * </query> * :: */ public void searchData(String criterionName, String criterionValue, int resultSize) { System.out.println("The maximum number of records to return is " + resultSize); }
Note: The xm prefix and its URI are declared implicitly in any JWS file. However, you must declare the namespace prefix and URI to use the prefix in XMLMAP files.