1

I'm looking to a way to connect a COM+ legacy application to a WCF Service, i have been researching this since a couple of days and i haven been lucky to find any useful information, can anyone point me into the right direction on this?

I Need the old COM+ component to make calls to a new C# WCF Service so I Need some kind of proxy in the COM Component that abstracts the communication with the Service.

Thanks in advance, i really appreciate any help.

Bongo Sharp
  • 9,450
  • 8
  • 25
  • 35
  • 1
    have you checked out this thread http://stackoverflow.com/questions/1068762/calling-c-from-c-reverse-p-invoke-mixed-mode-dlls-and-c-cli – AndrewB Jul 03 '10 at 00:08
  • yes, it is possible to create a proxy in C# and then consum that on c++, is there an how to for this? thanks! – Bongo Sharp Jul 03 '10 at 17:22
  • 1
    Please be more precise about what you need. Do you need your existing COM+ code to make calls to the service, or do you need the service to make calls to your COM+ code? – John Saunders Jul 06 '10 at 02:25
  • I Need the old COM+ component to make calls to a new C# WCF Service – Bongo Sharp Jul 06 '10 at 17:07

2 Answers2

1

I assume you mean that you have a WCF service, and that the code that runs your WCF service needs to make calls to your legacy application and send that data in/out of the WCF service, correct? If that's the case, then the WCF facet of your question is actually irrelevant.

What you're trying to solve is how to get your .NET application to speak COM to your legacy application.

Check out: Introduction to COM Interop and COM Interop Tutorials.

You'll need to generate type libraries for your COM component, reference them and System.Runtime.InteropServices in your C# project, and then you can make your calls across into COM boundaries of your legacy application code. There are a lot of other examples and tutorials out there if you search for COM Interop Tutorial, for example.


EDIT:

I thought more about your problem. You need to implement a proxy by creating a server that "looks" just like your old server (all the same COM+ interfaces etc etc), and then forwards the request (by crafting a new request) to your WCF service. You can do this in C#. I whiteboarded (archive) the basic idea around it from your original whiteboard.

Mike Atlas
  • 8,193
  • 4
  • 46
  • 62
  • Hello, actually is the other way around, i want the legacy applications to call the WCF Service, so i need to have a communication proxy on the COM to perform the calls to the WCF Service. – Bongo Sharp Jul 02 '10 at 23:39
  • No problem, have you ever faced this same problem? – Bongo Sharp Jul 02 '10 at 23:44
  • Well, I suppose you can build your proxy using my answer as a starting point, right? You need some .NET code that can talk to your legacy app over COM, and then translate that data to calls on the WCF service? – Mike Atlas Jul 02 '10 at 23:48
  • 1
    If that is not the case, I don't understand the directionality of the data you're trying to move around. Maybe you could draw a diagram? http://dabbleboard.com/draw?b=Guest387466&i=0&c=2b0c1680f8a08432b982115cfed959b8ce748146 – Mike Atlas Jul 02 '10 at 23:51
  • this comes from a trouble were we have an adapter for a desktop application, so you have clients that are communicating to this adapter which then talks to a mainframe, the constraint in this problem is that we cannot change the client desktop code, so the only thing we can change is the actual adapter to communicate to the WCF service, ill take a look at the documentation you provided, thank you! – Bongo Sharp Jul 02 '10 at 23:54
  • This is the draw http://dabbleboard.com/draw?b=Guest387466&i=0&c=2b0c1680f8a08432b982115cfed959b8ce748146 – Bongo Sharp Jul 03 '10 at 00:16
  • See my edit above, Bongo. http://dabbleboard.com/draw?b=Guest387466&i=0&c=2b0c1680f8a08432b982115cfed959b8ce748146 – Mike Atlas Jul 06 '10 at 02:14
  • Thanks for you response Mike i really appreciate it, i think i got the idea, I'm going to implement it and let you guys know how it went :), again thanks – Bongo Sharp Jul 06 '10 at 17:06
  • You're welcome. An upvote is a great way to say thank you. If it gets you along far enough to solve your problem, then you can accept the answer (green check mark). – Mike Atlas Jul 06 '10 at 18:18
0

The WCF service moniker can auto-generate a COM proxy for your WCF service. Your C++ code can call this proxy directly without the need for you to write any C# proxy code or explicit COM interop code.

Look at http://msdn.microsoft.com/en-us/library/ms729739(VS.85).aspx for details.

I particularly recommend this feature primarily because I owned the feature at Microsoft.

Andy Milligan
  • 400
  • 4
  • 10