Signum Framework Logo
"Open framework that encourages convention over configuration, using C# code,
not XML files, to model at the right level of abstraction and achieve deadlines.
...but also has a full Linq provider, and syncs the schema for you!"
Login
RSS

Search

»



Main
Index
Map
Videos
Download
Source code
Tutorials
Forum
FAQ



Image



PoweredBy

In order to make the communication possible yo first need to set up the service in the server application.

Test if the service Url is working in your browser (in our example, http://localhost:7654/ServerBugs.svc) before continuing.

Let's see an example of how to set-up the connection from the client side for a simple interface in a shared assembly like this:

namespace Bugs.Contract
{
    [ServiceContract(SessionMode = SessionMode.Required)]
    public interface IServerBugs : IBaseServer, IViewServer //ILoginServer, IExcelReportServer
    {
      
    }
}

Step 1: Setting up the Client WPF EndPoint

We usually set-up WPF adding this configuration to your WPF config:

<configuration>
...
  <system.serviceModel>
    <bindings>
      <wsHttpBinding>
         <binding name="friendBinding" closeTimeout="01:00:00" openTimeout="01:00:00"
                  receiveTimeout="01:00:00" sendTimeout="01:00:00" maxReceivedMessageSize="8388608">
          <readerQuotas maxArrayLength="2147483647"/>
        </binding>
      </wsHttpBinding>
    </bindings>
    <client>
      <endpoint name="server"
          address="http://localhost:7654/ServerBugs.svc" 
          binding="wsHttpBinding" bindingConfiguration="friendBinding" 
          contract="Bugs.Contract.IServerBugs" />
    </client>
  </system.serviceModel>
</configuration>


Signum Framework doesn't impose anything else to WPF connection than IBaseServer and using NetDataContract on any method. You're still free to play with WCF configuration

Step 2: Create a custom ServerBugs class

It's usually convenient to write a static class in your application to handle the connection and re-connection to the server. A very simple one could be like this:

    public static class ServerBugs
    {
        static ChannelFactory<IServerBugs> channelFactory;

static IServerBugs current; public static IServerBugs Current { get { return GetCurrent(); } }

public static IServerBugs GetCurrent() { if (current == null || ((ICommunicationObject)current).State == CommunicationState.Faulted) { if (!NewServer()) throw new ApplicationException("Connection with the server is needed to continue"); }

return current; }

public static bool NewServer() { try { if (channelFactory == null) channelFactory = new ChannelFactory<IServerBugs>("server");

current = channelFactory.CreateChannel();

return true; } catch { current = null; throw; } } }

This code gets more convoluted when you are using authorization: When you create a new session you need to asking the user for authentication.

We haven't found an Authorization mechanism that fits all needs jet, so we aren't providing any. Is up to you to build it.

Finally, note that using ServerBugs.Current you find the transparent proxy using your own server interface (IServerBug). This is usually more convenient than using Server.CurrentProxy for your own custom ServiceOperations because you save the cast.

Step 3: SetServerFunction

At the very beginning of your application (we use Main method), set the server function:

Server.SetServerFunction(ServerBugs.GetCurrent);
Creative Commons License Signum Framework Site by Signum Software is licensed under a Creative Commons Attribution 3.0 License.
Powered by ScrewTurn Wiki version 3.0.5.600.