I have to develop a Windows Service in .NET/C#. The service must be accessible from a VB6 application.
My first idea was to host a WCF service in a Windows Service, but the VB6 application needs a wrapper for the service to be able to consume it. This is not an option.
Now I'm thinking of using sockets, but is this the best approach? If not, what would be the best design?
I would like to know what my options are, and what are the pros and cons for these options?
Any advice is much appreciated
You can host your WCF services as COM+ applications.
Once you have a WCF service hosted in COM+, you can generate a type library from the COM+ application and then reference that in your VB6 code.
Note that you'll have to have the .NET runtime installed on the machine that the WCF service is hosted on (but not on the machines that you install a COM+ proxy on if using distributed calls).
The WCF service is still an option, but you would have to ensure the WCF configured binding is interoperable (choose BasicHttpBinding for example as seen here: WCF Bindings In Depth).
On the VB6 side, you can call an existing SOAP endpoint, as described here for example: How to Consume a SOAP Web Service in VB6?
Related
I already have a Windows Service project that runs scheduled tasks as part of a larger application. I want to add some Web Services to it (i.e. SOAP), so that some .NET clients can connect and request services (this is all on a LAN, not over the internet). The server application is a Service Project with references to some class library projects.
Is this something that can be done, or does the web service require that I create an ASP.NET project? Sorry for the very basic question, but I'm not sure where to start.
You can create a new WCF service without creating an APS.NET webservice and you can use SOAP to communicate with it.
Maybe this MSDN link can help you more.
The answer is that a Windows Service can "self host" WCF WebServices using the ServiceHost class.
Relevant article: Hosting and Consuming WCF Services.
Specific section: Hosting in Windows Services.
I’m currently working on a web service application project which will run in IIS7 on Windows Server 2008. The web services will be invoked from various clients, from outside the server but also from other components from within the same server. (Other web services and windows services)
My view is that the purpose of web services is to expose functionality so that external clients can invoke it. I really don’t see much sense in a web service invoking another web service on the same server or a windows service invoking a web service on the same server. Please correct me if I’m wrong?
I’ve started looking into WCF, but I’m quite confused.
Would it be more appropriate to do the following?
Instead of a web service project implement a WCF service.
Expose two endpoints:
1)One, which will be exposed using traditional web service binding which will be invoked from external clients.
2)Another endpoint so that internal services, (other web services or windows services) can invoke them, supposingly more effectively, surpassing a security layer as these are aplications already running on the server.
Would my approach be correct or am I overcomplicating things?
Any suggestions or links which could point me in the right direction appreciated.
Thanks
A web service calling another web service?
If they have different responsibilities I think it's a good idea to separate them. You get better separation on concerns (easier to share with other projects / code bases), easier maintainability and independent deployability.
I would go with WCF and have two different endpoints for the different consumers, and for example use net.pipe for communication on the same server (if the client supports it) and http for external clients.
I think WCF gives you more power and flexibility that old xml web services, and the configuration part is really good.
BasicHttpBinding will give you most interoperability with external clients.
named pipes will give you the best efficiency when both services are hosted on same machine.
BasicHttpBinding is like old asmx & XML web services.
Exposing both endpoints is AOK!
One service calling another service is NOT unusual.
Hosting multiple services on same machine is common. In the enterprise, running multiple instances of SQL-Server is commonplace. Of course it depends on hardware, services & response times.
The scenario is like this:
I have a .NET 4.0 client-Server application that works fine.
I need to create a UserControl that can access the Server, but it needs to be created in .NET 2.0 (because customer application is .NET 2.0)
Does it exist a way to access .NET 4.0 WCF service from a 2.0 client?
NOTE:
it is not a Web service, but a standalone .exe server
No autentication used
Data transfered are almost basic (class with arrays and basic types within)
it uses client callbacks so protocol il net.tcp
optionally I can change protocol if I can still be able to use callbacks
You need to expose the WCF as a Web Service:
How to: Expose WCF service also as ASMX web-service
Expose WCF Service as Traditional Style Web Service .asmx
The you work as if it was a good old .asmx service (add reference and so on).
It doesn't matter if your WCF service is hosted in a .exe, a web app, a windows service...
Supporting callbacks is not possible in .NET 2.0 with .asmx services, so that you have to simulate a callbak using something like TcpListener and TcpClient.
Unfortunately this has to de done from scratch, but you can use the logic in the WCF implementation.
If your WCF 4.0 service is using basic http binding, you can use it in .NET 2.0 or in any other language.
Just use WSDL.exe to generate the proxy and use it in .NET or in any other language.
Yes you can use the WCF service in .net 2.0 client by adding the reference of the .cs file (proxy class) in your client project.
Question solved a while ago.
Well, not really solved...
After looking at an article about performance on .NET WCF, I decided to use .NET remoting.
It is faster, compatible native .NET 2.0 and it works.
We're hosting a WCF web service on a server running the latest version of Windows Server.
We have many different clients running different versions of Windows. For example, 2000, XP, Vista and a couple of Windows 7.
Can I run a program that consumes a WCF service in Windows 2000? What do I need for a WCF service to run well on the client side?
A WCF service can be consumed by any client that can communicate with SOAP. The performance of the WCF service has nothing to do with the client OS. If performance is an issue with the WCF service it is most likely a connectivity or bandwidth issue from the client to the server. How you choose to consume the service is up to you. The WCF service will continue to run on your server and perform any methods you invoke from the client on the server.
Its very hard to answer your question without knowning the requirements of the web service which is exposed on the 'latest version' of windows.
The most important part of this will be "which binding(s) is/are being exposed by the WCF service".
If this is 'basicHttp' or 'wsHttp' you will be able to communicate with this service using a .Net 2.0 client (wsdl.exe proxy). If this is not the case, it will become harder to implement.
Bottom line; a Web Service is not tied in to the development platform it has been written on. The real important part of a web service is it's contract (which is described by WSDL). If the contract exposed can be consumed by .Net 2.0 tools, you can communicate.
If they cannot, you either have to use 'extensions' (like WSE) or go the manual route which i both advise not to take!
ps; WCF != WebServices. WCF is a toolkit that can be used to build a web service or rest service. "Traditional webservices used the Basic Profile 1.1" which consist only of XML, XSD, WSDL and SOAP.
hope this helps,
I using two WCF services. WCF service A is hosted in my .NET Winform application and WCF Service B is hosted on a Windows Service.
I am able to instantiate a client for WCF Service B and use the methods - i.e. call the WCF service hosted on Windows service from the .NET Winform app.
I am not able to accomplish the reverse with WCF Service A - i.e. call the WCF Service hosted on the .NET Winform application from the Windows Service. The call to the method times out.
I have used the WCF Test client from the Visual Studio command prompt and it can successfully make calls to WCF Service A.
Is this due to a security issue or something from the Windows Service?
Please advise.
Thanks in advance!
Subbu
I think the only viable approach (without the extreme of having some messaging infrastructure), is to have the service invoke operations back on your client via a WCF callback. A good example of this can be found here:
What steps do I need to take to use WCF Callbacks?
This is good for dealing with events that happen server side and allowing the client to respond to them. If events isn't what you're looking for, then your client could just register with the server (specifying the callback contract), and then the server can invoke your client at will.