10.8. JAX-RPC Mapping FileThe J2EE-standard JAX-RPC mapping file helps the JAX-RPC compiler map Java objects to WSDL objects. If the Java objects are complex, the JAX-RPC and WSDL files also will be complex. Example 10-4 is the inventory-mapping.xml JAX-RPC mapping file that the JAW Motors application uses. Example 10-4. inventory-mapping.xml<?xml version="1.0" encoding="UTF-8"?> <java-wsdl-mapping xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://www.ibm.com/webservices/xsd/j2ee_jaxrpc_mapping_1_1.xsd" version="1.1"> <package-mapping> <package-type>com.jbossatwork.ws</package-type> <namespaceURI>http://localhost:8080/jbossatwork-ws/types</namespaceURI> </package-mapping> <package-mapping> <package-type>com.jbossatwork.ws</package-type> <namespaceURI>http://localhost:8080/jbossatwork-ws</namespaceURI> </package-mapping> <java-xml-type-mapping> <java-type>com.jbossatwork.dto.CarDTOArray</java-type> <root-type-qname xmlns:typeNS="http://localhost:8080/jbossatwork-ws/types"> typeNS:CarDTOArray </root-type-qname> <qname-scope>complexType</qname-scope> <variable-mapping> <java-variable-name>cars</java-variable-name> <xml-element-name>cars</xml-element-name> </variable-mapping> </java-xml-type-mapping> <java-xml-type-mapping> <java-type>com.jbossatwork.dto.CarDTO</java-type> <root-type-qname xmlns:typeNS="http://localhost:8080/jbossatwork-ws/types"> typeNS:CarDTO </root-type-qname> <qname-scope>complexType</qname-scope> <variable-mapping> <java-variable-name>id</java-variable-name> <xml-element-name>id</xml-element-name> </variable-mapping> <variable-mapping> <java-variable-name>make</java-variable-name> <xml-element-name>make</xml-element-name> </variable-mapping> <variable-mapping> <java-variable-name>model</java-variable-name> <xml-element-name>model</xml-element-name> </variable-mapping> <variable-mapping> <java-variable-name>modelYear</java-variable-name> <xml-element-name>modelYear</xml-element-name> </variable-mapping> <variable-mapping> <java-variable-name>status</java-variable-name> <xml-element-name>status</xml-element-name> </variable-mapping> </java-xml-type-mapping> <service-interface-mapping> <service-interface>com.jbossatwork.ws.InventoryService</service-interface> <wsdl-service-name xmlns:serviceNS="http://localhost:8080/jbossatwork-ws"> serviceNS:InventoryService </wsdl-service-name> <port-mapping> <port-name>InventoryEndpointPort</port-name> <java-port-name>InventoryEndpointPort</java-port-name> </port-mapping> </service-interface-mapping> <service-endpoint-interface-mapping> <service-endpoint-interface> com.jbossatwork.ws.InventoryEndpoint </service-endpoint-interface> <wsdl-port-type xmlns:portTypeNS="http://localhost:8080/jbossatwork-ws"> portTypeNS:InventoryEndpoint </wsdl-port-type> <wsdl-binding xmlns:bindingNS="http://localhost:8080/jbossatwork-ws"> bindingNS:InventoryEndpointBinding </wsdl-binding> <service-endpoint-method-mapping> <java-method-name>findAvailableCars</java-method-name> <wsdl-operation>findAvailableCars</wsdl-operation> <wsdl-return-value-mapping> <method-return-value>com.jbossatwork.dto.CarDTOArray</method-return-value> <wsdl-message xmlns:wsdlMsgNS="http://localhost:8080/jbossatwork-ws"> wsdlMsgNS:InventoryEndpoint_findAvailableCarsResponse </wsdl-message> <wsdl-message-part-name>result</wsdl-message-part-name> </wsdl-return-value-mapping> </service-endpoint-method-mapping> </service-endpoint-interface-mapping> </java-wsdl-mapping> This JAX-RPC mapping file tells JBoss that the InventoryEndpoint Service Endpoint Interface has a findAvailableCars( ) method that takes no parameters and returns a CarDTOArray. Mapping between WSDL data types and Java object types is tedious. Notice how one return type, CarDTOArray, explodes into two <java-xml-type-mapping> elementsone for the CarDTOArray itself and the other for the CarDTO. Besides mapping a Java object to a WSDL data type, each <java-xml-type-mapping> element lists each of the object's data members with a <variable-mapping> sub-element. |