calling a WCF service object method in another WCF service - c#

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.

Related

How to make an Asynchronus call to WCF service from a smart device application?

I am developing a smart device application, which is going to communicate with a wcf service over wi-fi. As there is no option to add a service reference into a smart device project I decided to use the NetCFSvcUtil.exe. Everything works great!
But...
In the end I understood that the application must interact with the service in the background.
Having read this article Microsoft .NET Compact Framework Background Processing Techniques. I decided to use the Asynchronous Web Service Call. There http://msdn.microsoft.com/ru-ru/library/aa347733.aspx I found the /async parameter, but it appeared to not work for the NetCFSvcUtil.exe.
What can I do to get the async proxy for my smart device application? Is there a way to generate it or I'm expected to add async methods to the interface with my own hands? Maybe it would be suitable for .Net CF to use SvcUtil.exe to generate the async proxy in my case?
A further more information like which platform you are using to build your Smart phone application would be helpful.
I have done Blackberry development and consumed web services. There are two ways you could build your web services
RestFul Service - Consumption of web services would be pretty easy. Posting data could be a little pain as multipart form data is posted as stream in Wcf - Rest Starter Kit
Soap Service - If you decide to use SOAP, then for blackberry and Android you have to use preverified KSOAP -2 to send and receive soap messages between your app and the web service. If you decide to use KSOAP -2 , go back ASMX services. Somehow WCF services does not communicate with KSOAP -2 (due to change in SOAP version or something) where as a simple ASMX service works pretty smoothly. There are dozens of article which you could use to learn how to use KSOAP
he original idea was to host it in a windows service...
Windows Services could never be web facing. If you want any thing to be web facing, you need a Web Server !
In the end it worked. The "Add web reference" tool created a proxy with Begin/End async methods and the proxy interacted with the wcf service hosted by a simple console application (later a windows service) through the URL property of the proxy.

Communication between WCF and hosting Windows Service

This question is a Follow up to This
In the project I am currently working on, I have a windows service which is actually a TCP/IP server which is connected to some set of hardware.. The windows service collects data from the hardware and stores into a database and may also send some configuration commands to the hardware.. There is an asp.net website through which the user may ask the windows service for some data or even send some configuration commands for hardware through windows service..
As of now I am considering to host WCF inside the windows service and make asp.net to consume this service.. So, I want the WCF to invoke some of the procedures in my windows service when the user requests through the website.. is it possible? if it is please explain..I have searched a lot for this type of communication but all in vain.. if it is not possible suggest me some alternative approach to WCF... Please help, will be grateful.
If you make your WCF service a singleton you can create an instance to it and pass that to the ServiceHost. You can pass constructor an interface implemented in the windows service which the WCF service can use to talk to the Windows service - this interface implementation can act as a broker for the communication between the WCF service and the windows service

Can I run a program that consumes a WCF service on Windows 2000?

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,

Can I use WCF for communicating (sending message) between 2 windows service?

Can I use WCF for communicating between 2 windows service? If yes, How?
It depends on the type of message you want to transfer. There is a lot of possible solutions:
MSMQ messages
Duplex contracts
Named pipes
Basically you need to setup a WCF service on each windows service. You can use the WCF 4.0 discovery features to dynamically find the each service.
Sure; you'd usually define a service contract (interface) which the two services will use to exchange messages; then one of the windows services would host a WCF service (in this case, where the two services are in the same machine, you'd usually use a local-only binding, such as named pipes). Then the second win service can act as a client for the WCF service on the other windows services. Is there any specific issue you're facing?
Yes, It is possible. You can use ServiceHost class to host a WCF service in a windows service without dependency to IIS.

How to assess a Windows Service hosted WCF service from another WCF service hosted in IIS7?

I have done a work which contains two parts
WCF service which is hosted in Windows Service
WCF service project hosted in IIS7
I have done both comfortably,But i got a problem?
I want to call a method from WCF service hosted in WS from the 2nd WCF service hosted in IIS, but i was unable to do that? Can anybody help in this?
You should be able to configure a client endpoint in the service being hosted in IIS to the service being hosted as a Windows service, and make your call through a proxy just as you would normally make a call to a WCF service.
Well, if your service hosted in IIS7 wants to call the other service, it needs to become a client of that other service.
So basically, in Visual Studio or on the command line, you need to create a service reference to your second service, so that you'll get a client-side proxy class, which you can then use to call the second service. Also, you will need to add some configuration settings to your web.config for the service hosted in IIS7 in order for it to be able to call the other service (in a Windows service).
So where exactly are you stuck??

Categories