Consuming a WCF Service using wshttp binding from a C++ client

Recently I have been testing the interoperability of our WCF services. Our services use wshttp bindings, custom security and some WCF extensions. My first target language is C++ and I’m starting off with VC++ in VS2005 with .net 3.0 on the machine.

VC++ does not have the same options for generating service references as C#. There seems to just be one method “Add Web Reference” that uses sproxy.exe behind the scenes. I tried this method first and ran into some problems. I then tried a rather interesting method where the proxy is generated as a C# class library that the C++ client uses to communicate with the web service.

  • Create your C++ client in VS2005
  • Add a new project to the solution of type C# class library
  • In the C# project add a service reference to your web service
  • in the C++ project add a reference to the C# project
  • in the C++ project add an app.config file
  • copy all the gubbins from the C# app.config into the C++ app.config
  • follow this guidance to make your C++ client use the app.config

About Alex McMahon

I am a software developer, interested in .net, agile, I've previously specialised with .net 3.0 technologies like WCF, whereas now I am trying to specialise in agile development and best practice and patterns. I am obsessed with looking at the latest technologies, tools, and methods, and trying them out. I am currently employed by Rockwell Collins in the UK.
This entry was posted in .net, C++, development, wcf, web service. Bookmark the permalink.

2 Responses to Consuming a WCF Service using wshttp binding from a C++ client

  1. Robin says:


    I have vc++ application using vs2005. I may need it to connect as a client to a WCF service. What is the best approach for me within vs2005 to approach this? Your instructions seem very relevant to what I need to do. Can you make any further suggestions to help get us going?

    Thanks for a good post!


  2. Jay Varma says:

    Use a proxy from the client and call the appriopriate method on the WCF service. You can have the studio to create a proxy or using the channel factory.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s