How to connect a C++ COM To a WCF Service - c++

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.

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.

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.

Related

What is the difference between a Web-Service and a Application-Service

This might be a silly question on this site, but I want to learn more about it.
Being in the Software Engineering field, I have come to know that it's useful to get acquainted with Web-Services. I am trying to understand it. To do so, I must know the difference between a Web-Service and a Application-Service in simple terms.
I have heard about SOAP & REST Services.
For a newbie like me, its overwhelming to understand these concepts when I search them in Google.
How to understand these things better and in what order?
I think it's a great and simple question which usually confuses most of developers. What is Application Service and what is web Service?
Web service is a common term which you can find easily on the internet. Although some time they cross each others boundaries but here is a simplest explanation I can think of:
Application service or Application Layer is an abstraction layer reserved for communications protocols and methods designed for process-to-process communications. Application layer protocols use the underlying transport layer protocols to establish host-to-host connections.
Some time you can also use Application Service to define method calls within your application.
WebService: Any application or method which can be accessed by web is a Webservice. You can also say: anything available on the web is WebService.
There are three common web service architectures:
RESTful resource-oriented,
RPC-style e.g. SOAP
REST-RPC hybrid. 90% of the web sites use this unknowingly e.g. http://mysite.com/get/pictures?tag=birthday :)

Is there any problems when using Delphi to create Web-Service client?

I plan to start developing web-service client using Delphi XE. It looks like creating web-service client on delphi is easy to do.
Is there any bugs or problems when creating WebService on Delphi XE?
Is there any problems with other versions of Delphi (not XE) ?
(To create web-service i plan using WSDL-importer dialog)
Please, place Delphi version, you used to create web-service in answer.
I have created several webservice-clients in Delphi, all by using the wsdl. I have not encountered any problems so far. I have encountered some small problems, but nothin that couldn't be resolved with Google or Stackoverflow :-)
It depends. To answer your last question first, later versions of Delphi are better at generating a Web service client than earlier versions.
As for your first question. I have also created a number of Web service clients (and servers) using various versions of Delphi (most recently, Delphi 2007 and Delphi XE, though I also used Delphi 6, Delphi 7, and Delphi 2005). When the Web service methods use simple data types in its method parameters and return values (strings and integers), Delphi often does a good job of generating the client code using the WSDL importer. When complex data types are involved (objects, for example), it might be more challanging. For example, if the Web service uses complex types, and the WSDL is the only source of information about those types (you did not create the Web service, there is no documentation, or you cannot get the source code to it), it might take more work. It really depends on how complex the complex type is.
Additionally, if the Web service employs additional features such as authentication or other specialized headers, you will have to manually modify the code created by the WSDL importer. However, as birger noted, most of these issues can be resolved with research.
On the other hand, if the Web service was created in Delphi, it is usually very easy to create the Web service client.

How to connect a C++ program to a WCF Service?

In the place I work there are some software written in C# and some written in C++ (the most important ones). Some time ago we decided it would be a good idea to track any possible problem in the software, by sending stack trace and exception information over a web service. So I came with a WCF Service, that gets the information and store them on a database and send an automatic e-mail. It worked, we had to secure it through password, it's done, but now I want our other software, the one written in C++, to use this webservice (this software is used both on windows and linux, so we can't just make a call to another software in the user machine).
I've googled about it, and found this tutorial on how to use gSOAP, which so far didn't help me very much (lots of errors, it is not very detailed, and the web.config file is impossible to read). I was wondering if is there any other way to achieve this. In adition, since I'm using authentication on my webservice, it now has a wsHttpBinding (which AFAIK isn't supported by gSOAP).
Can you guys help me out?
Since your WCF service is in C# with .NET, and the only issue is getting the C++ application to be able to talk to it, one way is to follow the advice in REST / SOAP Endpoints for a WCF service and related articles.
Your C# programs continue to have the full SOAP access to your service.
Your C++ programs could do something like this for REST access:
"Browse" to the HTTP GET URL for the service command you wanted.
Then toss (or parse and use) whatever response came back.
It is a pretty minimal change to your WCF service to offer both SOAP and REST.
The REST ability opens your service to JavaScript as well as C++ clients.
You may need to restrict the interface to simple data, or class objects that are easy to parse in C++.
Will the machines running the C++ applications have the .NET Framework installed?
Check out: Create WCF service for unmanaged C++ clients

What is a good platform for devoloping web services in C++?

We're looking at developing a Web Service to function as a basis for a browser display/gui for a networked security prototype written in C++. My experience with web services has been limited to Java. I prefer Web Services in Java because it's on the "beaten path".
One sure was to do this would be to simply code a Java client which invokes the web service, and call it as a command line with parameters from the C++ code.
It's not ideal, since generally speaking an API is preferable, but in this case it would work and be a pretty safe solution.
A resource which does handles web service development in C++ is called gSOAP, at this url: http://gsoap2.sourceforge.net
Any thought on which is a better approach? Has anyone used gSOAP, and if so, what did you think?
I'd done things with gSOAP, it's not awful. I'm increasingly opposed to the RPC model for web services, though; it forces you into a lot of connection and session state that adds complexity. A REST interface is simpler and more robust.
To me is Axis C++.
For RPC style, have a look at Thrift,
I found it quite better ( faster, clearer, a lot of languages implementations) than soap.
My colleague ended up using a combination of Axis2 / java (for the service) and gsoap for the client. He created the wsdl from the Java service by generating it from a C++ header (using c2wsdl (?) or something like that. He said it was better than using a Java interface because that generated two sets of wsdl, for seperate versions of soap.
Then he used wsdl2java to generate the webservice and a test web client. Once we got that working, he used gsoap to create the web client (in C++), and it worked fine.
thanks for all the answers! I ended using a combination of them.
I had very good experience with gsoap - very simple, performance is good.
If it is acceptable to run only on Windows, there is a brand-new API for that purpose: WWSAPI
Instead of calling the java client from the command line, you can create a java virtual machine inside your C app, instantiate the class and call any methods. This is what the java.exe app does and I think the source code is included in the jdk.
Depends on how low level you want to go. You might checkout yield.

Can WSDL 2.0 (or similar) be used to generate a web service boilerplate?

I apologize if if this is a bonehead question.
I've used WSDL to generate code to talk to web services, but my question is about using it to actually generate web services.
Let's say that I have a device that is going to communicate with a web service. The web service in question doesn't actually exist and is out of my control. That is, the party wishing to process messages from my device must implement the service.
The service in this case is extremely basic. It's simply a small collection of methods that receive messages and return status codes. It's basically a middleman between my device and 3rd party software.
It would be really cool if I could supply something like a WSDL 2.0 document that they could then use to actually generate the boilerplate code for the service and methods they are required to implement...preferably in Java (Axis) and .NET friendly frameworks.
In other words, I want to use WSDL to generate the service, not the client. Or maybe I don't want WSDL at all. What techniques would you recommend to make this as painless as possible?
SvcUtil.exe for the Windows Communication Foundation technology in .NET 3.0+ can do some of what you're asking, i.e. generation of contract interfaces and basic client code using a predetermined WSDL as input.
Now, this will not fully generate the actual service, just the contract interface. I don't know of an easy way to do this as it is probably not a very common case. Essentially what you're asking is a slightly more automated version of what Visual Studio does when you create a class and use the "Implement interface" feature (which I believe is accomplished mostly through VS templates).