Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Deliver Next-Generation SOA Apps with Microsoft Robotics Development Studio  : Page 3

Bringing together the best of concurrent and distributed development, Microsoft Robotics Development Studio (MRDS) services allow you to create useful service-oriented applications.


advertisement
Contract Class
When you select the Visual Studio template, the project automatically adds class files which represent the contract and implementation class. If you named the project MouseTracker, then the contract class will be named MouseTrackerTypes.cs. This is where you will define the state variables and DSS operations associated with the service.

The following important elements are contained within the contract class:

  • Contract
  • State Variables
  • Message Operations
The contract contains the information that other services will need to use this service. The Universal Remote Identifier (URI) associated with the MouseTracker service is included by default when you create the project using a template. This identifier should be unique to the service and must be preceded by the DataMember attribute, such as in the following code snippet:

[DataMember()] public const String Identifier = "http://schemas.tempuri.org/2008/05/mousetracker.html";

Since the goal of the mouse tracker project is to track the mouse position, it makes sense to include the mouse coordinate points as state variables. To do this, add variables, preceded by the DataMember attribute to the class named MouseTrackerState:


//Add the Mouse position as a state variable private PointF _mousePos = new PointF(); [DataMember] public PointF MousePos { get { return _mousePos; } set { _mousePos = value; } }

The last important element in the contract class is the message operations. Services created with the template include one main operations port, in which all service operations should be posted. Any operations that need to be performed for a service must be defined in the services PortSet.

The PortSet, which is created by default when you use the Visual Studio template, includes three standard message operations (DsspDefaultLookup, DsspDefaultDrop, and Get). In addition to these operations, you will need to include operations named HttpGet, UpdateMousePosition, and Replace. The code implemented in these operations will be covered in a later step. For now, we are just defining the list of valid operations that can be posted to the port. The PortSet for the MouseTracker service should look like the following:

[ServicePort()] public class MouseTrackerOperations : PortSet<DsspDefaultLookup, DsspDefaultDrop, Get, HttpGet, UpdateMousePosition, Replace> { }

The GET operation, which is included by default when you use the template, will return XML as a SOAP message. For the MouseTracker service, include the HttpGet operation, which allows you to return the XML as HTTP instead. HttpGet is used since you'll query the state through a web browser in a later step. The UpdateMousePosition handler is responsible for updating the MousePos state variable defined earlier. And finally, the Replace operation is responsible for updating all of the state variables for the service.



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap