26.05 26.02 25.11 25.08 25.05 25.02 24.11 23.11 Cloud Enterprise
26.05 26.02 25.11 25.08 25.05 25.02 24.11 23.11 Cloud Enterprise

Working with SOA services




Creating the weather service definition

Learning activity

To create the weather service definition:

  1. In NexJ Studio, create a new Service Definition using the File > New > SOA Definition menu options and name it training:Weather. 

  2. In the Source tab, drag and drop or enter the following code:

    XML
    <SOADefinition name="training:weather">
       <Service>
          <Interfaces>
             <Interface default="true" ref="main"/>
          </Interfaces>
       </Service>
       <Interfaces>
          <Interface name="main">
             <Method name="getWeather">
                <Arguments>
                   <Argument name="cityName" type="string"/>
                </Arguments>
                <Result type="weatherResult"/>
             </Method>
          </Interface>
       </Interfaces>
       <Types>
          <Type name="weatherResult">
             <Attributes>
                <Attribute name="tempurature" type="decimal"/>
             </Attributes>
          </Type>
       </Types>
       <Bindings>
          <Binding protocol="trpc"/>
          <Binding protocol="soap"/>
       </Bindings>
    </SOADefinition>
    


  3. In the Interfaces tab, create a new interface called main.

  4. Add a method called Creating the Weather Service Implementation.

Creating the Weather Service implementation

Learning activity

To create the Weather Service implementation:

  1. In NexJ Studio, create a new implementation using the File > New > SOA Implementation menu options, and enter the name: training:Weather. 

  2. In the Source tab, drag and drop or enter the following code:

    XML
    <SOAImplementation service="training:weather:1.0">
       <Interface name="main">
          <Method args="cityName" name="getWeather">
             <Script><![CDATA[(:: training:weather:1.0:type:weatherResult
       :tempurature  
       (case cityName
          (("Toronto" "Chicago" "New York") -5)
          (("Milan" "Madrid" "Barcelona") 7)
          (("Dheli" "Sydney") 24)
          (else 20)
       )
    )]]></Script>
          </Method>
       </Interface>
    </SOAImplementation>
    
    


Adding the service to the environment file

Learning activity

  1. In your environment file, add the following code in the SOAConnections section.

    XML
    <SOAConnection auth="perimeter" binding="context" service="training:weather:1.0"/>
    


  2. See if you can access the WSDL for the service at http://localhost:7080/training/soa/training:weather:1.0/soap?wsdl.

You'll have the opportunity to try the service in the next learning module.