Saturday, June 7, 2008

Services

Today's blog content is found in Sara Morgan's book. You ought to buy it since I can't (and won't) re-publish it here for free. Today is a summary of services. Everything here is out of that book. I really recommend you do the service tutorials - it would provide deeper understanding and insight into what is mentioned. This is a summary for academic purposes.

Some terms:
Manifest - is an XML document which stores the services that are to be started.

Contract - Information that other DSSs need so that they may use the service. [MORE INFORMATION]

DSS Proxy - Provides stubs for communicating with the services, rather than allowing other services to directly communicate with one another

Transform - The DSS proxy exposes the service contract, the transform acts between the service and the proxy, making communication possible

Partner - "...represents a service that is tied to another service"

And then some useful C#
When you make a method that has the DATAMEMBER attribute, an intrinsic attribute in Microsoft.DSS.Core.Attributes.DataMember, it is indicating that that the public property must be serialized as XML.

The ServicePort attribute defines the URL of the service! This is where you will be accessing the state information, so make a mental note! It is found where the _mainPort (the type of which is your operations class) is declared.

I also need to learn about the yield keyword in c#. [MSDN]

Useful tidbits
  1. Make sure, in the service tutorials, that you add the name of the operation in the {service_name}Operations PortSet list. It's something I missed the first time
  2. Change the prefix of the namespace. It is found in the {service_name}Types.cs and in the manifest file. It ensures successful DSS in more distributed environments.
  3. The auto generated assemblies: There are three created per service: the service, proxy and transform. The naming standard is as follows: {service_name}.Y{year "yyyy"}.M{month "MM"}.{blank, "Proxy" or "Transform"}.dll
  4. The ServicePort attribute defines the URL of the service (found in the {service_name}.cs file)
  5. Page 29-30 Table 2-3 has the list of DSSP operations (you may write your own, but these are the povided ones)


Messages in services consist of three parts:
1. Action - "Typically ... informs the runtime of an action to be performed." (eg. HTTP GET)
2. Body - "...represents the XML found in the Microsoft.ServiceModel.Dssp.GetRequestType instance."
3. Response port - Informs the user of where to send response messages.

I am looking for the place where the ServiceHandlers are, if anyone has found them in the C# 2008 MRDS version. I would imagine it would have to be defined in the {service_name}.cs file (in the {service_name}Service class), since that is where the _state variable is declared. I inserted the code that Miss Morgan said was created by the VS Template (since I could not find it), and it worked fine. Well, fine in that no errors were thrown, I cannot say that just because no errors were thrown it actually worked...

But regardless, Service Handlers' behaviour can be set to one of five settings: Concurrent (does not modify state), Default (A kind of auto-detect), Exclusive (for state modification service handlers), Independant (will execute concurrently to all behaviours) or TearDown (marks the handler as a one-time operation, after which the service will be shut down).

The partnerships are pretty well covered in service tutorials four and five. I was really scared to run mine, but it worked like a charm!

Extra reading:
[More information on SOAP and HTTP interacting with services]

0 incoming messages (comments):