HelloWorld sample - Different approach

Hi,

The HelloWorld sample which is given by part of CSF 3.0 Dev edition is totally different from how the document explains.

In Helloworld Sample,

To get response from Session, ISessionManagerAdminResponse has been used.

But documentation recommends,

derive from CsfService and use SessionActions.SessionActiveNotification and SessionActions.SessionTerminatingNotification.

Could you please let me know is there any specific reason to use ISessionManagerAdminResponse and which approach is best one

Rgs

Vasu



Answer this question

HelloWorld sample - Different approach

  • John.NET

    Hello Vaasu,

    ISessionManagerAdminResponse contains method signature for accepting responses only from the SessionManagerAdmin service. So you need to define [Operation.. ] attribute to get the response from other services. See the example below.

    namespace CsfTesting

    {

    public class CsfClientService : CsfService

    {

    public CsfClientService()

    {

    //

    // TODO: Add constructor logic here

    //

    }

    public void CreateSession()

    {

    // Code to create session

    // Here use sender.SendAsync(message); from Microsoft.ConnectedServices.Sdk.Client 's MessageSender

    }

    private void TerminateSession()

    {

    // Code to create session

    // Here use sender.SendAsync(message); from Microsoft.ConnectedServices.Sdk.Client 's MessageSender

    }

    // This is the Syntax to accept asynshronous responses for session creation

    [Operation(Name = "CreateSessionResponse", Action = SessionActions.CreateResponse)]

    private void CreateSessionResponse(CreateSessionResponse response)

    {

    }

    // This receives Acknowledgement that message has been routed to a service

    [Operation(Name = "RouteAcknowledgement", Action = SessionActions.RouteAck)]

    private void RouteAcknowledgement(RouteAck ack)

    {

    }

    // This receives actaul response from the service

    [Operation(Name = "RouteMessageResponse", Action = "namespace/RouteMessageResponse")]

    private void RouteMessageResponse(SoapEnvelope soapenv)

    {

    }

    }

    }

    To make this code run there two things that you have to take care of.

    1. Create end point reference receive responses in web.config

    Example:

    Addressing.EndpointReference serviceEpr = new Addressing.EndpointReference(new Uri( "soap.tcp://machinename:port/UIFormService"));

    Messaging.SoapReceivers.Add(serviceEpr, this);

    2. Specify the end point URL in the ReplyTo of the Message header

    Example:

    Header header = new Header();

    header.Addressing.To = new Uri(SessionUri);

    header.Addressing.Action = SomeSoapAction;

    header.Addressing.ReplyTo = "soap.tcp://machinename:port/UIFormService";

    When the service sends the response it will received at the RouteMessageResponse method. It also important to note that you need to include the application that created the session as a participant in the Session Manifest. You also need to mention the Route for the service response in the Routing table of the manifest.

    A typical participant entry will look like this

    <Participant timeout="30" role="Service" inChannelResponse="false" type="WebService">

    <ParticipantName>UIParticipant</ParticipantName>

    <ParticipantID>UIParticipant</ParticipantID>

    <ParticipantUrl>soap.tcp://TCS032933:9100/UiFormService</ParticipantUrl>

    </Participant>

    A typical routing entry will look like this:

    <Route>

    <Criteria>(ACTION EQ 'namespace/HelloWorldResponse')</Criteria>

    <Destination>UIParticipant[namespace/RouteMessageResponse]</Destination>

    </Route>

    Try this and see you can get the response.

    Regards

    Vikram


  • ming_68

    Thank you Vikram.

    I can able to create and terminate session without using ISessionManagerAdminResponse interface. But i could not able to get response from services. Is it possible to receive service's responses without implementing ISessionManagerAdminResponse If so,how to define attributes to receive HelloWorldResponse

    Rgs

    Vasu


  • BearerOfLoss

    Hello Vaasu,

    The CSF 3.0 HelloWorld sample uses ISessionManagerAdminResponse.

    Ofcourse the documentation has snippets w.r.t using deriving CsfService and using the [Operation .... ] attribute.

    If you are using ISessionManagerAdminResponse then you need to implement method body for all the method signatures found in the ISessionManagerAdminResponse interface.

    If you want to avoid implementing method body for all the method signatures of ISessionManagerAdminResponse then you can derive only the CsfService class and use the [Operation... ] attribute to solve your purpose.

    Regards

    Vikram


  • HelloWorld sample - Different approach