Creating the weather service definition
Learning activity
To create the weather service definition:
-
In NexJ Studio, create a new Service Definition using the File > New > SOA Definition menu options and name it
training:Weather. -
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>
-
In the Interfaces tab, create a new interface called
main. -
Add a method called
Creating the Weather Service Implementation.
Creating the Weather Service implementation
Learning activity
To create the Weather Service implementation:
-
In NexJ Studio, create a new implementation using the File > New > SOA Implementation menu options, and enter the name:
training:Weather. -
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
-
In your environment file, add the following code in the
SOAConnectionssection.XML<SOAConnection auth="perimeter" binding="context" service="training:weather:1.0"/>
-
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.