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!!!

Aug
13
2006

Making VSTO 2005 and WSE 3.0 playing together again

Today I am working on the security of my publishing web services for the next release of Tech Head Brothers Portal. The goal is to be able to post content on the portal using THBAuhtoring (you might get the source from Codeplex) a Word 2003 solution I developed. I wanted to build my proxy class like so:

PublishServiceWse service = new PublishServiceWse();

and then I was getting the following error:

{"WSE032: There was an error loading the microsoft.web.services3 configuration section."}

The solution went with a crazy idea: the trick is simple give full trust to your .config file.

Mar
18
2006

Yeah!!! :-) Publications are working.

Today is a big day with a really cool milestone for Tech Head Brothers website.

First I am able to publish/update content on the site with my new publishing tool; a word template using vsto 2005 and secured web services. This piece of code let me publish content with pictures, colorized source code, zip files for sample applictions and this directly out of Word 2003. Really cool!!!

Second I can also publish/update/delete news directly from my prefered blog tool: PostXING. By the way the 2.0 Beta 1.0 was realized and I have to say: "Chris you made an awesome work, congrats".

May
22
2005

Beeing a speaker

End of April, I was invited by Microsoft France (Thanks to Pierre and Mitsu) to speak about the solution, based on Word 2003, I developed to publish content on my web site Tech Head Brothers. The day was called "Rencontres Solutions Métiers sur Office" and was held in Strasbourg, France. Tech Head Brothers was even a partner for that event.

So I arrived in Strasbourg by car and met Mitsu. We prepared my notebook to be able to make the presentation. It was a nightmare to install his wifi pcmcia card on my notebook but after several trials it was working, but the connection was low. The goal of my presentation was to show the tool but to also make a live presentation of the publishing side of the tool with a live secured web service post to the site using WS-Security, WS-Policy, DIME attachment...

One of the other difficulties was that my web site was under attack since the weekend before the event. It was not crashing but on heavy load. It is really bad for such a presentation. But it went even worse...

After the pause it was our turn. Mitsu started his 30 minutes presentation and I was sitting on his left, trying to set my notebook to the resolution of the beamer that we forgot to set during the pause. After some parameterization I thought it was ok. So I was carefully listening to Mitsu presentation. Five minutes before my turn, I thought I missed one configuration for the beamer so I changed something, clicked apply, and boom, blue screen, on stage. At least it was not the screen shown on the beamer. I tell you in such condition you feel the adrenaline pumping up. So I quickly rebooted my machine prepared again demo, and at the time I was ready it was my turn to speak. After showing the Powerpoint presentation I made about the architecture of the tool, I started the demo, with lots of fear, because the wifi was showing low - very low and switch again and again. But believe it or not at the time I clicked the publish button, with finger crossed it worked. Then I could show the attendee the article directly on Tech Head Brothers : Windows Forms : développement d'un TabControl sans onglets... Then Mitsu continued his speech. And one minute after that IO had the wifi going from very low to disconnected. :-)

Some times the demo god is with you, and that was such a day :-)

Jan
27
2005

Interoperability Webcast: Security &amp; Interoperability with WSE 2.0, WebLogic and Axis (Level 300).

This evening I attended a webcast about web service interopearability. It was done by Michele Leroux Bustamante of IDesign. The subject was .NET and Bea Weblogic interop and was really interesting. I would like to see now the way to do the same development using Eclipse and deploying the Web service in Weblogic. One of the link to remember about this webcast is: Interop Warriors (such a nice name ;).

You might take a look to the upcoming webcast here: http://www.interopmonth.com/

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