Friday, 7 December 2012

Visual Studio vs2010 / vs2012 with WSE Security

Recently I had to access a WSE web service that send a security WSE token in the header in plain text. After scrapping about for about week and trying various fixes; which mostly did not work at all.  Below is the method that worked for me.

WSE has been abandoned since about 2005/2006 because by modern standards it fairly poor security and there is a good chance you will see old  WSE services used over http  rather than https which makes its use pointless.

Microsoft Stance on WSE
"WSE 3.0 is not officially supported because ASMX is seem as a legacy product and so its WSE. There is no release plan or service packs that will enable this support."

The following is a mix of my own experiments, posts and articles.

Download :   Web Services Enhancements (WSE) 3.0 for Microsoft .NET

Install this as you need a dll called : Microsoft.Web.Services3.dll

WSDL.exe  or WseWSDL.exe for Generating Proxy Classes

There are a lot sites/posts that say you need to generate the proxy classes via WseWSDL.exe. In anything over Windows  XP this requires a registery hack and the installation of .NET2.0 SDK.

I found WsWSDL.exe to be buggy and error prone and does not has the same functionality as WSDL.exe so...

DON'T use WseWSDL.exe unless you have to.

You Really Want to use WseWSDL.exe

If WseWsdl.exe can't find .Net 2.0 then...

  • Install  .NET 2.0 SDK
  • Open RegEdit 
  • Navigate to  HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework
  • Add String Key
  •                          Value Name : sdkInstallRootv2.0
  •                          Value Data :   C:\Program Files (x86)\Microsoft Visual Studio 8\SDK\v2.0
Value data will be the location of your .NET 2.0 SDK location, above is for Win7.

Using Normal WSDL.exe

Add a reference to Microsoft.Web.Services3.dll  to your project, I would also mark the reference to copy locally (eg bin folder) if you are going to deploy the code somewhere.

Add Using Reference in the proxy code:

using Microsoft.Web.Services3;

Change webclient proxy class from 

    public partial class MyProxy: System.Web.Services.Protocols.SoapHttpClientProtocol


    public partial class MyProxy: Microsoft.Web.Services3.WebServicesClientProtocol

So you are telling the webclient proxy generated from the WSDL.exe to use WSE3.0 instead of the standard it usually has.  This is basiclly what WseWsdl.exe should do (except it can mess even this up)

Sending Plain Text username and password in the SOAP header

All you do is send a security token as shown below.

  MyProxy myproxy = new MyProxy();

  myproxy.RequestSoapContext.Security.Tokens.Add(new UsernameToken("user", "password", PasswordOption.SendPlainText));

More BackGround / Reference

Find this useful ?  Then add a comment.


  1. ha yeah I have a feeling in about oh one day I'm going to wish I saw your post a week or so ago thanks! smh ...

  2. Dude you saved my day thanks a lot!

  3. Hey just wanted to thanks for this post, it saved my day.


Comments are welcome, but are moderated and may take a wee while before shown.