Not long ago, I posed a question to the Stack Overflow community – (is there a) “Good Visio Template (or alternative) for SOA/Distributed Systems?”.  Surprisingly, there was only one response!

Since then, I have been recently introduced to, of all things, a Java based tool called the ‘Quick Sequence Diagram Editor’ which can be used to produce really useful UML Call Sequence Diagrams.  Using this tool, you can effectively call out the interface definitions of your distributed services or service library.

image

The tool uses a pseudo code syntax to produce (render) the sequence diagrams.  Services (or classes) are declared first , and then subsequent code calls out the service behaviour (request/response, arguments).  It also supports inline annotations (comments) as well as conditional (branching) IF/ELSE logic.

Code is evaluated/rendered as you add the code so that it is impossible to model a sequence with invalid object names.

From the site, here are the principal features:

  • The diagram changes as you type.
  • Diagram code is instantly checked, errors are pointed at.
  • Diagrams can be exported and zoomed.
  • Long diagrams can be paginated.
  • There are constraints imposed on diagram specifications, so one cannot model something that is impossible to implement.

All it requires is Java (for your platform), the downloadable is an executable .jar file which consumes the specification files (which can be used with other UML document tools as well).

Enjoy

Download: http://sourceforge.net/projects/sdedit/

 

Hi There,

So chances are if you’ve read my subsequent posts, you’ll get the feeling that I’m working with some legacy web service applications.  You’d be right, and the challenge of Web Service Extensions (WSE) 3.0 is figuring out how to upgrade them to WCF (.NET 3.5/4.0) without harming the legacy clients who consume them.  We’ll call it a 1-2 punch combination – update the services, then we can worry about the consuming applications.

However.. there are a few challenges.  As it turns out, you don’t need to wrap WCF services with a WSE web application as I first suspected.  This will work, but it gives you an extra set (of legacy) web services and you don’t really need an extra set of bindings and configuration which could cause you trouble down the stretch.

The solution is somewhat straightforward, in that WCF (in .NET 3.5/4.0) supports WSE 3.0 compatible bindings.  Trouble is, you have to use a custom binding, and it has a tendency to require a secure transport (out of the box) which can throw you.

Here’s what MSDN has to say about using a backwards compatible binding with WCF:

To enable a WCF service to interoperate with WSE 3.0 clients

Define a custom binding for the WCF service.

To specify that the August 2004 version of the WS-Addressing specification is used for message encoding, a custom binding must be created.

  1. Add a child customBinding Element to the <Bindings> of the service’s configuration file.
  2. Specify a name for the binding, by adding a binding element to the customBinding Element and setting the name attribute.
  3. Specify an authentication mode and the version of the WS-Security specifications that are used to secure messages that are compatible with WSE 3.0, by adding a child Security element to the binding element.
    To set the authentication mode, set the authenicationMode attribute of the Security element. An authentication mode is roughly equivalent to a turnkey security assertion in WSE 3.0. The following table maps authentication modes in WCF to turnkey security assertions in WSE 3.0.

    WCF Authentication Mode = WSE 3.0 turnkey security assertion

    AnonymousForCertificate  = anonymousForCertificateSecurity

    Kerberos = kerberosSecurity

    MutualCertificate = mutualCertificate10Security*

    MutualCertificate = mutualCertificate11Security*

    UserNameOverTransport = usernameOverTransportSecurity

    UserNameForCertificate = usernameForCertificateSecurity

    * One of the primary differences between the mutualCertificate10Security and mutualCertificate11Security turnkey security assertions is the version of the WS-Security specification that WSE uses to secure the SOAP messages. For mutualCertificate10Security, WS-Security 1.0 is used, whereas WS-Security 1.1 is used for mutualCertificate11Security. For WCF, the version of the WS-Security specification is specified in the messageSecurityVersion attribute of the Security element.

    To set the version of the WS-Security specification that is used to secure SOAP messages, set the messageSecurityVersion attribute of the Security element. To interoperate with WSE 3.0, set the value of the messageSecurityVersion attribute to WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10.

  4. Specify that the August 2004 version of the WS-Addressing specification is used by WCF by adding a textMessageEncoding element and set the messageVersion to its value to Soap11WSAddressingAugust2004.

    ms730049.note(en-us,VS.90).gifNote: When you are using SOAP 1.2, set the messageVersion attribute to Soap12WSAddressingAugust2004.

  1. Specify that the service uses the custom binding.

    1. Set the binding attribute of the Service Endpoint element to customBinding.
    2. Set the bindingConfiguration attribute of the Service Endpoint element to the value specified in the name attribute of the binding element for the custom binding.

Example:

The following code example specifies that the Service.HelloWorldService uses a custom binding to interoperate with WSE 3.0 clients. The custom binding specifies that the August 2004 version of the WS-Addressing and the WS-Security 1.1 set of specifications are used to encode the exchanged messages. The messages are secured using the AnonymousForCertificate authentication mode.

<configuration>
  <system.serviceModel>
    <services>
      <service
        behaviorConfiguration="ServiceBehavior"
        name="Service.HelloWorldService">
        <endpoint binding="customBinding" address=""
          bindingConfiguration="ServiceBinding"
          contract="Service.IHelloWorld"></endpoint>
      </service>
    </services>

    <bindings>
      <customBinding>
        <binding name="ServiceBinding">
          <security authenticationMode="AnonymousForCertificate"
                  messageProtectionOrder="SignBeforeEncrypt"
                  messageSecurityVersion="WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10"
                  requireDerivedKeys="false">
          </security>
          <textMessageEncoding messageVersion ="Soap11WSAddressingAugust2004"></textMessageEncoding>
          <httpTransport/>
        </binding>
      </customBinding>
    </bindings>
    <behaviors>
      <behavior name="ServiceBehavior" returnUnknownExceptionsAsFaults="true">
        <serviceCredentials>
          <serviceCertificate findValue="CN=WCFQuickstartServer" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectDistinguishedName"/>
        </serviceCredentials>
      </behavior>
    </behaviors>
  </system.serviceModel>
</configuration>

So after defining your WCF services, instead of using a basicBinding or a wsHttpBinding, all you need to do is define a customBinding, like the one below:

<!– WSE 3 compatible binding –>

      <!– http://msdn.microsoft.com/en-us/library/ms730049%28v=VS.90%29.aspx –>

     
      <customBinding>

        <binding name="customWseBinding"> 
         <security messageSecurityVersion="WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10"

                    authenticationMode="UserNameOverTransport"

                    allowInsecureTransport="true">

          </security>

          <textMessageEncoding messageVersion="Soap11WSAddressingAugust2004" />

         <httpTransport authenticationScheme="Anonymous" />          
        </binding>     
      </customBinding>

Now, assuming all your other settings are set correctly, you might get excited when the page.. almost.. loads:

image

However, what is this?

Error: Security policy export failed. The binding contains a TransportSecurityBindingElement but no transport binding element that implements ITransportTokenAssertionProvider. Policy export for such a binding is not supported. Make sure the transport binding element in the binding implements the ITransportTokenAssertionProvider interface. ----> System.InvalidOperationException: Security policy export failed. The binding contains a TransportSecurityBindingElement but no transport binding element that implements ITransportTokenAssertionProvider. Policy export for such a binding is not supported. Make sure the transport binding element in the binding implements the ITransportTokenAssertionProvider interface.

Not what we were expecting?  Basically, httpTransport doesn’t implement the ITransportTokenAssertionProvider which is what is being expected by the customBinding.  To work around this you have to, unfortunately, implement your own custom transport.  It’s nasty, but it works.

To take a look at the classes you’ll need, please read this article or this article.

After implementing the custom handler, the binding looks like this:

<customBinding>

        <binding name="customWseBinding">

          <security messageSecurityVersion="WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10"

                    authenticationMode="UserNameOverTransport"

                    allowInsecureTransport="true">

          </security>

          <textMessageEncoding messageVersion="Soap11WSAddressingAugust2004" />

          <!–<httpTransport authenticationScheme="Anonymous" />–>

          <CustomHttpTransport authenticationScheme="Anonymous" />

        </binding>     
      </customBinding>

Which results in the following screen:

image

 

References

How to: Configure WCF Services to Interoperate with WSE 3.0 Clients

http://msdn.microsoft.com/en-us/library/ms730049%28v=VS.90%29.aspx

http://social.msdn.microsoft.com/forums/en-US/wcf/thread/ea0ff7b6-12c4-487d-a983-c07e06260acf/

 

Sometimes, for various reasons, we come across projects or solutions we have to maintain to our chagrin.  We have an application which runs on .NET 2.0 and can’t be upgraded to 3.5 or beyond.  This application consumes web services published via the old ASMX services, and uses Web Service Extensions 3.0 (WSE 3.0) – the precursor to Windows Communication Foundation (WCF).

If you are in the same position, and you have upgraded your solution to Visual Studio 2010 (but are still targeting .NET 2.0), you might find that, by default, updating those web references causes the base class to change from WebServicesClientProtocol to SoapHttpClientProtocol.

This is by design, as it is anticipated that all web services be upgraded to WCF, however sometimes this causes widespread destruction and it’s easier and more convenient to just be able to use the previous importer.  This can be done in Visual Studio 2010, but it is somewhat nasty.

Here is a step by step guide to enabling WSE 3.0 references in Visual Studio 2010:

1. Close Visual Studio 2010
2. Download and Install WSE 3.0 (if you haven’t already)
     a. http://www.microsoft.com/downloads/en/details.aspx?FamilyID=018a09fd-3a74-43c5-8ec1-8d789091255d
3. In Explorer, open the following folder:

a. C:\ProgramData\Microsoft\MSEnvShared\Addins (or)
b. C:\Documents and Settings\All Users\Application Data\Microsoft\MSEnvShared\Addins


4. Locate the following file:
     a. WSESettingsVS3.Addin
5. Open the file in Notepad
6. Replace <Version>8.0</Version> with <Version>10.0</Version>, then save
7. In Explorer open the following folder:
    a. C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE
8. Locate the following file:
   
a. devenv.exe.config
9. Open the file in Notepad
10. Add the following at the end of the file (before the </configuration>) and save:

<system.web>
<webServices>
<soapExtensionImporterTypes>
<add type="Microsoft.Web.Services3.Description.WseExtensionImporter,
Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35" />
</soapExtensionImporterTypes>
</webServices>
</system.web>

11. Open Visual Studio 2010
12. In Tools -> Options -> Environment->Add-in/Macros Security ensure that this entry exists:
       a. %APPDATA%\Microsoft\MSEnvShared\Addins
13. Update web references

References:

http://stackoverflow.com/questions/433062/wse-client-project-keeps-reverting-webservicesclientprotocol-to-soaphttpclientpro
http://www.junasoftware.com/blog/how-to-use-wse-3-in-visual-studio-2010.aspx
http://www.junasoftware.com/blog/how-to-use-wse-3-in-visual-studio-2008.aspx

 

Hi there.

Renamed in the .Net Framework 4.0 from “ADO.net Data Services” to the new – more snappy – “WCF Data Services”, today I’m going to take a closer look at what drives this latest version.  If you look at the release notes there are a number of additions (as well as obviously using the much better Entity Framework v4):

  • Data binding,

  • Counting entities in an entity set,

  • Server-driven paging,

  • Query projections,

  • Custom data service providers,

  • Streaming of binary resources.

To find out what else is new check out What’s New in WCF Data Services.  Also you might want to look at Getting Started with WCF Data Services http://msdn.microsoft.com/en-us/library/cc668810.aspx

To start, I am going to take a look at the server-driven paging since paging has typically been one of those areas of functionality where, if implemented poorly, can really degrade performance of a database or website.

What you’ll need:

  • Visual Studio 2010 Service Pack 1
  • SQL Server 2008 R2 [any edition] with Service Pack 1 – although this should in theory work fine with SQL Server 2005 and 2008.
  • AdventureWorks Sample Database

We’ll be using the old favourite AdventureWorks sample database so that we have some data preloaded.  You can obtain the latest version for SQL Server 2008 R2 from Codeplex at the following location: http://msftdbprodsamples.codeplex.com/releases/view/55926.  The installer does a great job of installing the samples for you, for this article we’re just going to use the OLTP demo database, so you can ignore the others for now.  See the screenshot below, which is how it should look after it is installed (via SSMS):

If you’re not too sure how to go about setting up an Entity Framework data source with AdventureWorks, check out this article from MSDN.com – though please note it is written for use with Visual Studio 2008, not Visual Studio 2010 Service Pack 1: http://blogs.msdn.com/b/adonet/archive/2008/06/18/tutorial-entity-data-source-control.aspx

image image

What we’re going to do is create a new Solution with an ASP.net Web Application.  Once it is created, add a Class Library to the solution and then add a new Entity Framework data model.  I’ve called mine ‘AdventureWorksModel’ as you can see in the screenshot.  Choose to generate it from a database, and select the AdventureWorks2008R2 database.

When I tried to generate the Model, I received the following error message: ‘Unable to generate the model because of the following exception: ‘The table ‘AdventureWorks2008R2.Production.Document’ was referenced by a relationship, but was not found.’

To work around it, I unselected all the tables in the ‘Production’ schema, and just added the remaining tables instead.  I’ll take a look at this error later to see if I can find out where the errant relationship is causing problems.

At any rate, you should now have a half decent model to play with:

image

..moving on.  In your ASP.net Web Application project, make sure you add a reference to the DataAccess class library.  Then, it’s time to create the data service:

  1. In Solution Explorer, right-click the name of your ASP.NET project, and then click Add New Item.

  2. In the Add New Item dialog box, select WCF Data Service.

  3. For the name of the service, type AdventureWorksDataServices.

image

Visual Studio will show you some generated code.  You’ll need to add the name of your Entity Framework Data Context in the definition of the WCF Data Service, like below:

public class AdventureWorksDataServices : DataService<AdventureWorksModelContainer>

In Part 2, we’ll be looking at how to configure the WCF Data Service and then how to use some of the new features. 

Part 2 will be coming soon.

 

Recently, I’ve come to find a lot of spare time on my hands and today I decided that I’ve been sitting on the sidelines long enough; it’s time I got my head into the various APIs and pricing models involved in “Cloud Computing”.

There’s a good reason I’ve been waiting – I’ve been waiting for the hype to die down, and for real world solutions to present themselves.  Both Amazon EC2 (Elastic Compute Cloud, part of Amazon’s Web Service offering) and Microsoft’s Windows Azure (incorporating SQLAzure, which has previously been reviewed on this site) have matured to the point where real world applications are making use of them, and I think it is fair to say that they are the big names currently associated with the cloud computing concept.

I’m excluding VPS (virtual private server) technologies, which are a (somewhat) more generic product/service for virtual hosts provided by web hosting companies, as they typically are hosted servers and lack a programmatic API such as Azure and Amazon EC2.  Their product is slightly different from the Cloud model offered by Amazon and Microsoft, although a VPS or Virtuozzo style setup would surely be a valid option for many businesses, depending on their scalability needs.

So, I’ll be starting with Amazon EC2 and a re-review of Windows Azure (I’ve previously used Azure and SQLAzure pre-RTM).  My main goal will be to compile a pricing comparison and to create a test cloud application and compare each platform.  Check back for more information as I begin looking into each platform.

Cheers.. R

 

You might find this information handy if you work with Windows Services, and wish to grant some basic permissions to user accounts.  In my scenario, I wanted to be able to list the status of several key Windows Services used in my overall architecture (for a diagnostic website/control panel) and to be able to restart the service(s) should they stop for some reason.

This has become increasingly difficult as, over time, Windows Server has become further locked down.  By default, local users and non-administrative accounts do not even possess the rights to even aggregate local services, let alone query their status or restart them.  Luckily, there is a way to remedy this.  Please note that this applies on a per Account basis, I have not found a solution which applies to security groups.

You’ll need a special utility (called Subinacl) to grant permissions, you can download a copy from  Microsoft hereNote that you will require local administrative privileges to perform the following steps.

The first thing you need to do is to [1] determine the SID (security identifier) of the account you wish to grant permissions to.  This can be achieved a number of ways, the easiest being the execution of a little VBS script.  Copy and paste the below VBS into a text file, save it with a .vbs extension,  and double click the file to execute.

strComputer = "."   ‘ — or the full name of the machine
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objAccount = objWMIService.Get _ ("Win32_UserAccount.Name=’<USERNAME>‘,Domain=’<DOMAIN OR LOCAL MACHINE NAME>")
Wscript.Echo objAccount.SID

Once you’ve obtained the SID for the account you wish to grant permissions to, read the following blog article – scroll down to the section titled “Grant access to run the Services Control Panel“.  This blog article will take you the rest of the way.  I strongly suggest reading through the linked article.

If, however, you’d prefer a quick summary of the remaining steps, keep reading below.

  1. Open a Command Prompt and execute the following statement:

    sc sdshow scmanager

  2. Copy the output (SDDL) to a text editor, it will look something like this:

    D:(A;;CC;;;AU)(A;;CCLCRPRC;;;IU)(A;;CCLCRPRC;;;SU)(A;;CCLCRPWPRC;;;SY)(A;;KA;;;BA)S:(AU;FA;KA;;;WD)(AU;OIIOFA;GA;;;WD)

  3. Copy the section of the SDDL that ends in IU (interactive users) to just before the S: in the SDDL line.
  4. Replace ‘IU’ with the SID of the user you looked up previously, it may look like this:

    D:(A;;CC;;;AU)(A;;CCLCRPRC;;;IU)(A;;CCLCRPRC;;;SU)(A;;CCLCRPWPRC;;;SY)(A;;KA;;;BA)(A;;CCLCRPRC;;;S-1-5-21-214A909598-1293495619-13Z157935-75714)S:(AU;FA;KA;;;WD)(AU;OIIOFA;GA;;;WD)

  5. Run the following command to grant the permission to enumerate local Windows services to the specified User Account/SID:

    sc sdset scmanager "D:(A;;CC;;;AU)(A;;CCLCRPRC;;;IU)(A;;CCLCRPRC;;;SU)(A;;CCLCRPWPRC;;;SY)(A;;KA;;;BA)(A;;CCLCRPRC;;;S-1-5-21-214A909598-1293495619-13Z157935-75714)S:(AU;FA;KA;;;WD)(AU;OIIOFA;GA;;;WD)"

You’ll need to know the “short name” of the Windows Service you want to grant permissions on, to do this quickly, type the following command:

sc getkeyname "<Service Name>”

You can also get the name from the Services applet in the Control Panel –> Administrative Tools.

Then, using subinacl (which you previously downloaded and installed, right?) you can grant permissions to your user account like so:

subinacl /verbose /service “<short name of service>” /grant=<DOMAIN or MACHINE>\<user account>=F

Note that the “=F” grants full permissions.

A big thanks to the two blog entries I’ve referenced for steering the way here.  I found the VBS script an easier way to lookup the user SID than the one referenced in the second blog article.

To grant enumeration rights to a security group, you may be able to follow steps outlined in the following blog article, though I have not tested it out myself.

Source Articles:

[1] http://blogs.technet.com/b/heyscriptingguy/archive/2004/12/03/how-can-i-determine-the-sid-for-a-user-account.aspx

[2] http://lanestechblog.blogspot.com/2010/07/how-to-delegate-services-control-in.html
[3] http://networkadminkb.com/kb/Knowledge%20Base/Windows2003/How%20to%20allow%20users%20to%20enumerate%20service%20remotely.aspx

 

Someone kindly posted this excellent flowchart in Stack Overflow which helps to identify the most appropriate WCF Service bindings to use in a solution.  There’s another version located here: http://architectopia.blogspot.com/2008/01/wcf-binding-decision-chart.html

wcfbinding

Not a bad little reference chart!

 

Well, it’s been a busy week.  Unfortunately it hasn’t left me with much time to write any meaningful blog entries – apologies.  Last Friday I managed to implement an end-to-end solution for object graph serialization with Entity Framework (v4) POCO objects to and from WCF Web Services (note: for .Net clients only at this stage). 

It is a fairly complicated thing to explain, so I’m only going to go into detail if there is sufficient interest in the solution.  There is sufficient material to be found on the Internet (see my previous post for links), but it’s certainly not all in one place and you would have to combine aspects of a different example – in the case of supporting serialization back from the WCF client (via a generated proxy).

The summary goes something like this:

  1. Create edmx model
  2. Generate POCO entities using the template support
  3. Split the entities into a separate assembly
  4. Consume the entities and context via a Web Service (WCF) facade
  5. Implement a custom attribute to handle EF Proxies
  6. Implement a custom attribute to handle cyclic references (for entities with a self-reference) – (if needed)
  7. Implement a custom attribute to be outputted in the client proxy stub – (if needed)
  8. Use the common assembly with the client and the WCF service

So – in short – if you are interested in a detailed entry (or series of entries) please leave a comment here, otherwise I may get to the subject later in the year when I have more time (and if there is interest).

In other news, I did some work with a WinForms client and TreeView control which was my first Windows Application for quite a while.  I’ve got to say, I’m really impressed how easy it is to use TreeView controls in .Net WinForms over MFC/C++.  Back in the old days, TreeView controls were a bit tricky to work with – .Net makes it almost too easy.

 

Today I have been modifying a very repetitious SSIS package which does bulk import of data form a flat file.  The Data Import Wizard is a pain when you want to import the same format but from different source files, especially since it is unstable and tends to crash when you make changes and try to re-run its SSIS package.

So I created a package using the Wizard, then created a new Integration Services project in Visual Studio 2008 (no word on when support will be added for SQL Server projects in VS 2010?).  I imported (add existing item) the package the Wizard created and started to much around with adding variables so that I could set the input file path and the destination table name before executing the SSIS package in question.

The power here is we only have to set column definitions and the schema of the destination once, rather than having to re-jig every time we go to (manually) import from a flat file.  Below is what the wizard-generated SSIS package looks like:

image

The package created by the Wizard uses a hardcoded table name (for the destination) and input file paths (pointing to the source flat file) – so in order to work around this I had to do the following:

- change the hardcoded destination table (which is defined in a Script task) to something generic
- add a second SQL Task which renames the generic table to the value we want from config
- add a configuration for the package (so I can set the source path and the destination table name)

So here is the Control Flow of the package, now modified, from the original rendition:

image

The second task simply calls a system stored procedure to rename our “generic” table (in this example called, tmp) to a name set by configuration:

image image

Note here that I have created a User defined variable which is then set via configuration.  Speaking of configuration, how does one go about establishing an external config file for an SSIS package?  Actually, it’s quite easy..

image

Right click your package designer and select “Package Configurations…”.  Create a new configuration, and use the wizard to specify the location to store the file, and the settings you wish to override via the configuration.  It’s all very simple, I’m not going to go into detail here.  You can see the settings in the screenshot below.

image

You can also set the values of your Data Source components – in the case of the flat file connection manager, this is the ConnectionString property.  Anyhow, hope this entry helps any of you who are lost in overriding SSIS settings using configuration!

R

 

Today I feel obliged to link to the almost unknown utility, SQL Server Migration Assistant  for MS Access.
This is a fairly helpful tool which can simplify migrating Schema and data between two otherwise fairly incompatible products.

What is interesting to watch is how the Assistant migrates queries to views and so forth.
It’s such a shame that replication to SQL Server CE couldn’t be more like this.

I’ve used this tool twice to migrate data from earlier (read:primitive) MS Access databases that I used to use for proof of concept projects.

A typical example is a database of our DVDs (>1,000 rows) and the SSMA does a great job in migrating the data.  Although I’ve ojnly used it twice, I’d be interested to see whether it can do a better job of ETL (Extract/Transform/Load), because the Access DB grew to be denormilized over time and when porting to SQL it would be nice to try and normilize the data into a new schema.

Anyhow, give it a try if you need to migrate data from MS Access to SQL Server. 
Remember: if you aren’t completely satisfied, you can always get your money back (by way I’m pointing out that it’s made available for $0).

 

Aussie Wine Guy


© 2012 Rob Sanders: Sanders Technology Suffusion theme by Sayontan Sinha
WordPress SEO fine-tune by Meta SEO Pack from Poradnik Webmastera