views:

304

answers:

1

Can anyone tell me what Step-by-Step actions take place when a WCF Clients connect to a WCF Service and calls an Operation?

Plz describe the steps with step number and maintaining the serial.

Alternatively plz provide me with a web link that describe these steps.

+1  A: 

Check out

I'm not quite sure what you're looking for, or what it is that you're most interested in - can you possible clarify?

You need to take into account the two parts : client and server.

The server is a class that exposes methods, and it needs to be hosted somewhere - in IIS or in an app of your own. In your self hosting scenario, you create a ServiceHost, which hosts one service class. There are 1-n endpoints defined on the service, and those are "opened" and listening for incoming requests.

The server has several options that influence how the service class will be instantiated, and how incoming requests will be handled.

One property on the ServiceContract is the InstanceContextMode, which can be:

  • PerCall: for each incoming request, a new service class instance is created and it handles the call and then terminates; this is typically the recommended setting
  • PerSession: a client establishes a session with the service and the service instance will stick around until the client is done and indicates this, or until inactivity timeouts kick in
  • Single: there's only ever a single service class instance, which handles all requests (singleton). If the singleton is single-threaded, this means the requests are serialized and handled one after another. In order to allow multiple requests being serviced at the same time, the singleton needs to be multi-thread aware, and all internal variables etc. need to be protected from concurrent access (things get a lot more complicated and messy with multiple concurrent access)

The other, related option is ConcurrencyMode, which can be Single (only a single request can be handled by a single service class; this is the recommended setting for Per-Call activation; it's the easiest model), Reentrant (which is basically the same as Single, with the exception of duplex callbacks being allowed back in - only ever used if you have Duplex channels), and Multiple which is the best choice if you have a singleton service and needs performance - but the programming model gets a lot trickier and more demanding.

The client also needs to know (by config or in code) where to call to for the service.

What the client basically does (and the server basically does it backwards) are these steps:

  • take in one or several parameters (int, string, your own types)
  • it will then serialize those parameters into a message
  • typically it will encrypt and sign the message (optional)
  • it will then transmit that message to the server over the wire

There are more optional steps in between - the client could add headers to the message, it could do other things to it - but these are the most steps.

On the server, once the message is received, these steps happen:

  • the message is received on an endpoint
  • the message is checked, decrypted etc.
  • the message is deserialized into parameters and objects
  • the dispatcher figures out (based on message info, like the SOP action) what object and what method to call
  • that method is then called and the message parameters are passed in

Once the message has been processed on the server, now the server creates a response message and basically send it back the same way (serializing, encrypting, etc.) and the client receives it and interprets it.

Marc

marc_s
Can u plz describe the instantiations of contracts and calling Operations in this steps. I.e. description from coding perspective.
JMSA