Sep
7
2008

Video of Tech Head Brothers new authoring tool based on Word 2007

In the following video I present the different features of the new authoring tool for my portal Tech Head Brothers.

First you will see the use of ClickOnce to enable easy installation on the author computer. This will also allow an easy update scenario. A great plus compared to the past.

Then you will see the Word 2007 template using to author the content of an article. It shows:

  1. Definition of the Title
  2. Definition of the Description
  3. Definition of the Keywords
  4. Writing of the content of a section of content with bold, italic, list, hyperlink
  5. Adding some sample code directly copied from Visual Studio 2008
  6. Inserting sample code in a zip
  7. Adding a picture captured using SnagIt yo the article
  8. Offline preview in Internet Explorer
  9. Posting to the Tech Head Brothers web site with Tags selection
  10. Online preview of the posted content

Enjoy the video! (Without sound, I couldn’t find a micro at home :()

Sep
6
2008

New step in my authoring tool using Word 2007

This evening I took the time to implement a new step on the new version of Tech Head Brothers authoring tool.

Now I am able to write an article in Word 2007 and post it using Web Services.

The next picture is the result of posting from Word 2007 on the web site using Web Services:

Here is how it looks like in Word:

To insert some source code sample as you can see on the Word 2007 picture or the web site, it is really easy. Go in Visual Studio, copy the code you want in the clipboard. Switch to Word 2007, then use the Source Code button:

To insert a picture, either use Windows Explorer to copy a file into the clipboard and paste it into the Word 2007 document, or use a tool like SnagIt from TechSmith (Thanks for the license by the way!!), make a screen shot, copy result into the clipboard and paste into Word 2007.

Is that easy!

This tool will make the authoring process on Tech Head Brothers so easy.

Jun
27
2007

Migration from WSE 3 to WCF

I started to migrate the Tech Head Brothers authoring tool and portal from Web Service Enhancement 3 (WSE 3) to Windows Communication Foundation (WCF). This is a next step in the integration of .NET Framework 3 in Tech Head Brothers portal.

Till today I was using WSE 3 from the Word VSTO solution to securely publish content to the portal directly out of Word 2003/2007.

The migration went straight due to my initial implementation that was already using interfaces and implementation classes. So basically I had to :

  • Remove the reference to WSE 3 and add one to System.ServiceModel
  • Change the attributes on the interface to ServiceContract and OperationContract
  • Update the web.config to parameterize the new WCF endpoint, binding...
  • Regenerate the client proxy and update a bit the client code

This first step took me around 1h30 and was working very good but was still missing all the security of the old version.

Then to implement the security part of the web services:

  • I created a new certificate
  • Removed the Policy using the self developed aspnetUsernameTokenSecurity that is not needed anymore
  • Configured the web.config with a new wcf service behavior using userNameAuthentication and serviceAuthorization linked to ASP.NET providers
  • Replaced code checking the role of the user calling the service with an attribute PrincipalPermission
  • Regenerated the client proxy and reconfigured it

So now I have security at the level of the message that is encrypted using the certificate and at the web service with role access check.

Currently the solution uses attributes to check the role of the user that access the web service. I don't find the solution flexible enough and the next step will be to have the configuration in a configuration file, that would let me change access rights without changing any line of code.

As always when this will work I will publish the source code of the VSTO client authoring tool (Tech Head Brothers Authoring) on the codeplex project: THBAuthoring.

Jun
22
2007

Legacy code integration using Windows Communication Foundation (WCF) and Java Axis in a Service Oriented Architecture

What are the options when you need to integrate Windows legacy code in a heterogeneous Service Oriented Architecture (SOA)?

The proposed problem was to expose a set of Windows C++ DLLs to a global SOA platform written in Java. Those DLLs would be then exposed as backend computation services.

One of the options used in some past projects was to use the Microsoft SOAP Toolkit. But your C++ DLLs needs to be COM Objects for that. I experienced it and still have production code running with it. It works quite well even with surprising complex data structures. But as today it is definitely not the way to go.

The service oriented world has evolved rapidly over the last years and using such an old deprecated technology (Microsoft SOAP Toolkit) is not really efficient for a project.

So at last it was time to check .NET in this entire Java world ;-)

The general idea was to define a layered solution. From bottom up I first defined an interoperability layer using .NET Interop to be able to call the C++ DLLs from .NET. Then on top of this first layer I added another layer exposing the whole as a web service.

Now that I had the backend web service working I had to call it from Java. So are all those promises of web service interoperability just working out of the box?

Yes and No. You need to first have a real look at the different frameworks stack you want to use. For example, when you are working with Java Axis you are tied to SOAP 1.1, so you have to take care that the other side can understand this version of the SOAP standard.

So what do I have? First I have a client that must be written in Java using Axis 1.2-1.4 using SOAP 1.1, then a C++ Windows DLL backend that must be exposed in an interoperable way. By luck I was free to choose the technology used on that backend. Both ASP.NET web services (ASMX) and WCF can interoperate with the SOAP 1.1 standard, so I decided to go on with C# and WCF.

The way I approached the problem was to go on iteratively, making a first proof of concept to integrate the C++ layer with the .NET layer, then to integrate this upper layer with WCF and a .NET client to finally finish with a Java client.

Due to the ease of the interface exposed by the web service I didn’t wrote it using data contract design first. In more complex scenarios I would definitely go on with it because it leads to better success with interoperability.

So I finally adopted the following final solution.

Adopted solution

On the backend a Windows Communication Foundation web service written in C# using the .NET Framework 3.0. The web service layer uses .NET interop to make a call to the legacy C++ Dlls.

On the client side; a Java 1.5 proxy/stub class generated using WSDL2Java out of the WSDL exposed by the service.

Hosting

The last question concerning the web service was to define the way I wanted to host it?

Two possibilities in my case: Windows Service and Internet Information Services (IIS).

After making some load test on the web service I realized that it was leaking memory so I finally went to the IIS solution because it provides you all the services for recycling a buggy process. It was also easier because some part of the deployment process for web services hosted in IIS were already implemented and tested.

Faced problems

The first minor thing I went through was to check which versions of WCF and Axis are compatible.

Then the C++ interop was the main work because it is not such an easy task to marshal between the different worlds in a correct way.

And finally the last one was that the legacy C++ Dlls where using ifstream to load configuration ini files, without a possibility to specify the full path of those files. As the web application was running in the Application Pool process (w3wp.exe), loading the ini file was using the base path of w3wp.exe; C:\WINDWS\System32\inetsrv\. That would force me to deploy the ini files in that folder. What an ugly solution. Adding the bin folder of the application to the PATH was not making the trick too. And as we couldn’t change the C++ Dlls I had to find something else.

The solution I came to, thanks to David Wang (yes you also Richard ;-), was to use this little method before calling into the legacy Dlls, changing the current directory:

        /// <summary>
        /// Sets the current directory.
        /// </summary>
        private static void SetCurrentDirectory()
        {
            string binpath = Path.Combine(HostingEnvironment.ApplicationPhysicalPath, "bin");
            Directory.SetCurrentDirectory(binpath);
        }

Conclusion

I really like the way WCF is handling the separation between the service description, the implementation and the configuration that will define how you expose the service to the world.

The other thing I still enjoy to see is complex systems using so different technologies talking to each other. Here we had a caller written in Java running on a Linux server calling a web service written in C# calling multiple C++ Dlls running on a Windows server.

I am still amazed about those little things!!!

About Laurent

Laurent Kempé

Laurent Kempé is the editor, founder, and primary contributor of Tech Head Brothers, a French portal about Microsoft .NET technologies.

He is currently employed by Innoveo Solutions since 10/2007 as a Senior Solution Architect and certified Scrum Master.

Founder, owner and Managing Partner of Jobping, which provides a unique and efficient platform for connecting Microsoft skilled job seekers with employers using Microsoft technologies.

Laurent was awarded Most Valuable Professional (MVP) by Microsoft from April 2002 to April 2012.

JetBrains Academy Member
Certified ScrumMaster
My status

Twitter

Flickr

www.flickr.com
This is a Flickr badge showing public photos and videos from Laurent Kempé. Make your own badge here.

Month List

Page List