10.9. WSDL FileThe WSDL file describes a Web Service interface along with its parameters and registers the web service with JBoss. If you thought the previous descriptors were tedious and painful to look at, then you're in for a treatthe WSDL file is much worse. Example 10-5 is the InventoryService.wsdl WSDL file used to deploy the Inventory Web Services. Example 10-5. InventoryService.wsdl<?xml version="1.0" encoding="UTF-8"?> <definitions name="InventoryService" targetNamespace="http://localhost:8080/jbossatwork-ws" xmlns:tns="http://localhost:8080/jbossatwork-ws" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns2="http://localhost:8080/jbossatwork-ws/types" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"> <types> <schema targetNamespace="http://localhost:8080/jbossatwork-ws/types" xmlns:tns=http://localhost:8080/jbossatwork-ws/types xmlns:soap11-enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://www.w3.org/2001/XMLSchema"> <complexType name="CarDTOArray"> <sequence> <element name="cars" type="tns:CarDTO" nillable="true" minOccurs="0" maxOccurs="unbounded"/></sequence></complexType> <complexType name="CarDTO"> <sequence> <element name="id" type="int"/> <element name="make" type="string" nillable="true"/> <element name="model" type="string" nillable="true"/> <element name="modelYear" type="string" nillable="true"/> <element name="status" type="string" nillable="true"/> </sequence> </complexType> </schema> </types> <message name="InventoryEndpoint_findAvailableCars"/> <message name="InventoryEndpoint_findAvailableCarsResponse"> <part name="result" type="ns2:CarDTOArray"/></message> <portType name="InventoryEndpoint"> <operation name="findAvailableCars"> <input message="tns:InventoryEndpoint_findAvailableCars"/> <output message="tns:InventoryEndpoint_findAvailableCarsResponse"/> </operation> </portType> <binding name="InventoryEndpointBinding" type="tns:InventoryEndpoint"> <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"/> <operation name="findAvailableCars"> <soap:operation soapAction=""/> <input> <soap:body use="literal" namespace="http://localhost:8080/jbossatwork-ws"/> </input> <output> <soap:body use="literal" namespace="http://localhost:8080/jbossatwork-ws"/> </output> </operation> </binding> <service name="InventoryService"> <port name="InventoryEndpointPort" binding="tns:InventoryEndpointBinding"> <soap:address location="REPLACE_WITH_ACTUAL_URL"/> </port> </service> </definitions> This WSDL file ties the InventoryService web service to the InventoryEndpoint interface and maps the CarDTO and CarDTOArray WSDL types to XSD data types. In the Client section, we'll use the WSDL file to generate proxy code that encapsulates the details of communicating with the Web Service. The following line in the WSDL file tells JBoss that it can choose its own URL for the web service: <soap:address location="REPLACE_WITH_ACTUAL_URL"/> By default, JBoss deploys our WSDL to the following URL: http://localhost:8080/jaw/ejb/Inventory?wsdl But we don't like the URL that JBoss uses, and we want to set the URL ourselves so it's meaningful to our clients. |