Archives

Archives / 2007 / July
  • Akropolis - Yet Another Way to Build .NET WinForm Apps...

    I just had a quick look at the demo videos on the Akropolis website and it looks pretty nice but it makes me wonder which tool you're supposed to be using in the future when you want to build a WinForms app (or whatever we're supposed to be calling a fat/smart client). Akropolis looks really useful if you want to create a standard looking application with WPF, that's for sure. This is what the home page states:

    Acropolis builds on the rich capabilities of Microsoft Windows and the .NET Framework, including Windows Presentation Foundation (WPF), by providing tools and pre-built components that help developers quickly assemble applications from loosely-coupled parts and services.

    From what I can see, Akropolis will be focusing on standard looking business client applications, but there is also support for themes, animations and stuff which they show off in their demos. Not sure why a business application would have that, but if it's based on WPF and XAML, it's easy to add bells and whistles I guess :) There is a CTP available for download on their website.

  • [WCF] Configuring the Service Client to Go Via TcpTrace

    TcpTrace by Simon Fell is a great tool to trace your HTTP and SOAP calls with, until you begin using WCF and it starts complaining about you not going directly to the service, address filter mismatch and all that. It's quite easy to fix that though, just add an endpoint behavior to your client configuration and tell it your're running via TcpTrace, like this sample:

    <?xml version="1.0" encoding="utf-8" ?>

    <configuration>

    <system.serviceModel>

    <bindings>

    <wsHttpBinding>

    <binding name="WSHttpBinding_IMyService" >

    <security mode="Message">

    <message clientCredentialType="Windows" />

    </security>

    </binding>

    </wsHttpBinding>

    </bindings>

       

    <behaviors>

    <endpointBehaviors>

    <behavior name="tcpTraceBehavior">

    <clientVia viaUri="http://localhost:8080/MessageSecurityWindows/Service.svc"/>

    </behavior>

    </endpointBehaviors>

    </behaviors>

       

    <client>

    <endpoint address="http://localhost:1035/MessageSecurityWindows/Service.svc"

    behaviorConfiguration="tcpTraceBehavior"

    binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IMyService"

    contract="MessageSecurityWindowsClient.MyService.IMyService"

    name="WSHttpBinding_IMyService">

    </endpoint>

    </client>

    </system.serviceModel>

    </configuration>

  • [WCF] Testing Message and Method Security with Windows

    While digging a bit deeper into Message and Method Security options for WCF services, I ran upon several good articles by Michèle Leroux Bustamante, both on TheServerSide.NET and on the That Indigo Girl blog she created for her book, "Learning WCF". I've just ordered the book and cannot wait to get my hands on it. I read several of the preview chapters she published on her blog and I really like the way she explains things. Good stuff, go get the book already!

    So I can't take credit for any of the code in this blog post, I'm just putting things up here for myself for safe keeping and for others to learn. The documentation and samples around message security on MSDN is also pretty good, for example - http://msdn.microsoft.com/en-us/library/ms730301.aspx

    So, this is a sample to do message security with a Windows client. It also shows how to make sure the caller belongs to a certain group or role to access it.

    SERVICE CODE

    So, to make sure the caller is a member of the Administrators group, you decorate the method with a PrincipalPermission attribute like this:

    [ServiceContract()]

    public interface IMyService

    {

    [OperationContract]

    string MyOperation1(string myValue1);

    }

    public class MyService : IMyService

    {

    [PrincipalPermission(SecurityAction.Demand, Role = "Administrators")]

    public string MyOperation1(string myValue1)

    {

    /// do something...

    }

    }

    SERVICE CONFIGURATION

    The service configuration needs to declare that message security should be handled by Windows.

    <system.serviceModel>

    <services>

    <service name="MyService" >

    <endpoint contract="IMyService" bindingConfiguration="wsHttpWindows" binding="wsHttpBinding"/>

    </service>

    </services>

    <bindings>

    <wsHttpBinding>

    <binding name = "wsHttpWindows">

    <security mode="Message">

    <message clientCredentialType="Windows" />

    </security>

    </binding>

    </wsHttpBinding>

    </bindings>

    </system.serviceModel>

    CLIENT CODE

    You don't need to do anything special for the client code part. Just make the call. The config file needs to be edited though.

    CLIENT CONFIGURATION

    Likewise, the client needs to declare the equivalent security means in its configuration file:

    <system.serviceModel>

    <bindings>

    <wsHttpBinding>

    <binding name="WSHttpBinding_IMyService" >

    <security mode="Message">

    <message clientCredentialType="Windows" />

    </security>

    </binding>

    </wsHttpBinding>

    </bindings>

    <client>

    <endpoint address="http://localhost:1035/MessageSecurityWindows/Service.svc"

    binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IMyService"

    contract="MessageSecurityWindowsClient.MyService.IMyService"

    name="WSHttpBinding_IMyService">

    </endpoint>

    </client>

    </system.serviceModel>

    It's all created for you if you "Add Service Reference", which of course requires you to first add an "mex" endpoint to the service.