I've just uploaded a new sample showing the use of WSE 3.0 from C++/CLI. The sample consists of a C++/CLI ASMX Service which allows users to upload/download files, query file information and list available files, and a simple C++/CLI Winforms client.

SimpleFileServer_Client.png The sample illustrates the following features:

  • UsernameToken-based authentication
  • Use of a simple UsernameTokenManager class for authentication (password==username)
  • MTOM use for upload/download of files between client and server

Some useful tips when creating WSE applications with C++/CLI are:

  1. To create the client-side proxy, don't use the Add Web Reference wizard in Visual Studio, instead use WSDL.EXE with the /language:CPP option and then add the generated .H file into your project. This is because you'll want to modify the generated code (to have the proxy class derive from WebServicesClientProtocol instead of the usual HttpClientProtocol), and the Add Web Reference wizard is not good for that: It actually compiles code to a separate DLL, and it also will re-generate the proxy code from the WSDL when you do a Rebuild-All.
  2. You can use policy files for both client- and server-side security policy configuration; the sample uses a very simple policy requesting UsernameToken based authentication. What you cannot do is use the WSE Settings wizard to edit the policy file directly. However, you can easily start with basic policy by copy-pasting it from the WSE documentation (watch out, errors abound!) or from one created in a sample C# project.
  3. Make sure you manually add a reference to Microsoft.Web.Services3.dll to your C++/CLI projects. You will also need to manually modify the Web.Config and app.config files to include the relevant WSE3 sections to them. For example, here's the web.config lines added for the service:


      <section name="microsoft.web.services3"

         type="Microsoft.Web.Services3.Configuration.WebServicesConfiguration, Microsoft.Web.Services3, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />






         <soapServerProtocolFactory type="Microsoft.Web.Services3.WseProtocolFactory, Microsoft.Web.Services3, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />






         <mtom serverMode="always" />




            <add localName="UsernameToken"

                 type="SimpleFileServer.CustomUsernameTokenManager, SimpleFileServer"




      <policy fileName="policy.config"/>



Hope someone finds this useful!


Tomas Restrepo

Software developer located in Colombia.