Lesson 1.2: Create and validate the WSDL file

The Temperature Conversion Web Services Description Language (WSDL) document is provided for you. The WSDL code that you use in this tutorial converts temperature from Fahrenheit to Celsius and Celsius to Fahrenheit.

Before you begin

Before you begin, you must complete Lesson 1.1: Set up the workspace and create the required projects.

About this task

You can create a new WSDL document or copy an existing one. The Temperature Conversion WSDL document that is used in this tutorial is provided for you in a simple project. Complete the following steps to copy the Temperature Conversion WSDL document into the workbench:

Procedure

  1. In the Enterprise Explorer view, expand TempEJB, right-click, and select New > Folder to create a folder that is called wsdl. Click Finish.
  2. Select the WSDL folder, right-click, and select New File.
  3. Name the file ConvertTemperature.wsdl.
  4. Click Finish.
  5. Copy and paste the following code to add the contents to the new file:
    <?xml version="1.0" encoding="UTF-8"?>
    <wsdl:definitions targetNamespace="http://sample" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://sample" xmlns:intf="http://sample" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
     <wsdl:types>
      <schema elementFormDefault="qualified" targetNamespace="http://sample" xmlns="http://www.w3.org/2001/XMLSchema">
       <element name="fahrenheitToCelsius">
        <complexType>
         <sequence>
          <element name="fahrenheitValue" type="xsd:double"/>
         </sequence>
        </complexType>
       </element>
       <element name="fahrenheitToCelsiusResponse">
        <complexType>
         <sequence>
          <element name="fahrenheitToCelsiusReturn" type="xsd:double"/>
         </sequence>
        </complexType>
       </element>
       <element name="celsiusToFahrenheit">
        <complexType>
         <sequence>
          <element name="celsiusValue" type="xsd:double"/>
         </sequence>
        </complexType>
       </element>
       <element name="celsiusToFahrenheitResponse">
        <complexType>
         <sequence>
          <element name="celsiusToFahrenheitReturn" type="xsd:double"/>
         </sequence>
        </complexType>
       </element>
      </schema>
     </wsdl:types>
    
       <wsdl:message name="celsiusToFahrenheitRequest">
    
          <wsdl:part element="intf:celsiusToFahrenheit" name="parameters"/>
    
       </wsdl:message>
    
       <wsdl:message name="fahrenheitToCelsiusResponse">
    
          <wsdl:part element="intf:fahrenheitToCelsiusResponse" name="parameters"/>
    
       </wsdl:message>
    
       <wsdl:message name="fahrenheitToCelsiusRequest">
    
          <wsdl:part element="intf:fahrenheitToCelsius" name="parameters"/>
    
       </wsdl:message>
    
       <wsdl:message name="celsiusToFahrenheitResponse">
    
          <wsdl:part element="intf:celsiusToFahrenheitResponse" name="parameters"/>
    
       </wsdl:message>
    
       <wsdl:portType name="ConvertTemperature">
    
          <wsdl:operation name="fahrenheitToCelsius">
    
             <wsdl:input message="intf:fahrenheitToCelsiusRequest" name="fahrenheitToCelsiusRequest"/>
    
             <wsdl:output message="intf:fahrenheitToCelsiusResponse" name="fahrenheitToCelsiusResponse"/>
    
          </wsdl:operation>
    
          <wsdl:operation name="celsiusToFahrenheit">
    
             <wsdl:input message="intf:celsiusToFahrenheitRequest" name="celsiusToFahrenheitRequest"/>
    
             <wsdl:output message="intf:celsiusToFahrenheitResponse" name="celsiusToFahrenheitResponse"/>
    
          </wsdl:operation>
    
       </wsdl:portType>
    
       <wsdl:binding name="ConvertTemperatureSoapBinding" type="intf:ConvertTemperature">
    
          <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    
          <wsdl:operation name="fahrenheitToCelsius">
    
             <wsdlsoap:operation soapAction=""/>
    
             <wsdl:input name="fahrenheitToCelsiusRequest">
    
                <wsdlsoap:body use="literal"/>
    
             </wsdl:input>
    
             <wsdl:output name="fahrenheitToCelsiusResponse">
    
                <wsdlsoap:body use="literal"/>
    
             </wsdl:output>
    
          </wsdl:operation>
    
          <wsdl:operation name="celsiusToFahrenheit">
    
             <wsdlsoap:operation soapAction=""/>
    
             <wsdl:input name="celsiusToFahrenheitRequest">
    
                <wsdlsoap:body use="literal"/>
    
             </wsdl:input>
    
             <wsdl:output name="celsiusToFahrenheitResponse">
    
                <wsdlsoap:body use="literal"/>
    
             </wsdl:output>
    
          </wsdl:operation>
    
       </wsdl:binding>
    
       <wsdl:service name="ConvertTemperatureService">
    
          <wsdl:port binding="intf:ConvertTemperatureSoapBinding" name="ConvertTemperature">
    
             <wsdlsoap:address location="http://localhost:9080/temperatureProject/services/ConvertTemperature"/>
    
          </wsdl:port>
    
       </wsdl:service>
    
    </wsdl:definitions> 
  6. Save the WSDL file.

Validating the WSDL document

The WSDL Validator can validate WSDL semantics and WS-I compliance.

About this task

You can validate the Temperature Converter WSDL document by following the proceeding steps:

Procedure

  1. Select the ConvertTemperature.wsdl document in the Project Navigator.
  2. Right-click, and click Validate. Any errors display in the Tasks view.

What to do next

If no errors occur during validation, you can proceed to create the web service.