Welcome Guest! To enable all features please Login or Register.



How to enable multi-request WCF service call sessions
#1 Posted : Saturday, October 6, 2012 7:11:32 PM(UTC)

Xomega Framework promotes a design pattern for a service layer that provides flexibility and reusability when defining and working with the service layer. This is described in details in the article on how to Build Flexible and Reusable WCF Services.

This approach requires ability to call several service operations within the same session, where changes from the previous calls will be visible in subsequent calls in the same session. The easiest way to enable this is to use WCF bindings that support sessions, such as netTcpBinding. In this case, you can create a WCF channel on the client side, call several operations on the same channel, and then close the channel.

Note, that Silverlight doesn't support such bindings, so you can read how to enable WCF conversation sessions in Silverlight.

The following snippet shows a client endpoint configuration that uses netTcpBinding.
    <endpoint name="IEmployeeService" address="net.tcp://localhost:8002/EmployeeService"

The method below demonstrates how Create, Update and Save Changes operations are called in sequence on the employee service within the same session to create or update an employer record.

private void btnSave_Click(object sender, RoutedEventArgs e)
    ChannelFactory<IEmployeeService> cfEmployee = new ChannelFactory<IEmployeeService>("IEmployeeService");
    IEmployeeService svcEmployee = cfEmployee.CreateChannel();

    // for new objects create the object and store a temporary key
    if (isNew) obj.FromDataContract(svcEmployee.Create());

    // update object values
    Employee_UpdateInput inUpdate = new Employee_UpdateInput();



Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.