WCF Data service, some question - c#

I've two questions on WCF Data service:
-98% of my needs are covered by the WCF Data service, I only need one business methods, is it possible to mix a WCF Data service? Or should I create a second WCF service only for this method?
-Is it possible to host a WCF Data service into an application? I've a server, and I want that this service is accessible only when the server is launched
Thank you very much

You can add service operations to your WCF Data Service: http://msdn.microsoft.com/en-us/library/cc668788.aspx
They don't have the same power as true WCF Service operations, but they should fullfil most of your needs in this area (note that they can actually return OData feeds/entries for the client consumption).
You can definitely host WCF Data Service in your own application. The overall description is here: http://msdn.microsoft.com/en-us/library/cc668805(VS.100).aspx, but there are bunch of samples around the web, just search for "host WCF Data Service".

Related

What are some scenarios in which you need ASP.net Web API to consume a WCF Service?

I know that ASP.net web service supports only HTTP protocol and with WCF you have more options like TCP and Named pipes etc. Can you think of any scenarios in which one might have to consume a WCF service through an ASP.net Web API?
Following would be one of them use case where you want to call wcf service from web API.
If you already have a wcf service running and available which is doing some complex operations and you do not want it to be available directly to your consumers, you can create a web API and call the wcf service to perform the complex tasks and let the consumers to use the web API. In web API you can put extra logic of validation and authorization of the incoming requests.
Wcf being an older technology it would be better to write something new and eventually replace wcf rather than maintaining it.
Also If the current wcf is setup is not available via http protocol then not all the clients can communicate with it. Web API has that edge over wcf service.
How web API would connect to wcf service?
This depends on lot of factors such as network, deployment strategy, security etc.
But following would be one of the examples.
If the wcf service is available on tcp and web API and wcf are running on the same network, then web API can call wcf.
There may be a different answer to this question based on what exact problem you are trying to solve.
My answer is based on what information you have provided and the experience I gained by solving similar issue in real life.

What tools/methods are used to consume WCF web services for Android?

I am designing an Android application which is supposed to connect to a server via WCF web service.
I have a WCF web service written in .NET 4.5 and it is a self-hosted web service. It has SOAP endpoint configuration and it is not a very complex service, however it does include some methods which return DTOs (Classes containing lists, other DTOs and value types).
Now the problem I am facing is that I wish to use some sort of tools to consume the web service definition and generate the proxy classes. I have been successful doing this with the help of Eclipse, but the resulting generated code uses alot of external libraries not available within Android.
Now my question is, what are the preferred tools/methods to consume WCF SOAP web services?
I found that using the following tool gave me the best generated code.
https://code.google.com/p/android-ws-client/
I do recommend this tool to anyone looking for consuming a WCF SOAP web service.

windows service as tier between code and webservice

This might be a simple question, but is it possible to use a windows service as a tier between my code and a webservice?
I have a rather large project, and a webservice. Instead of calling the WS directly, I need a tier inbetween. (There are reasons to why that's a good idea...)
Since a windows service is all ready present, can I call that service, and get that same service to call the webservice?
You could use wcf to communicate with a windows service, that than communicates with a webservice.
Or you could host a web service in the windows service, that communicates with the original webservice.
That are just two examples, so it es technical possible to match you requirements.

How to setup WCF proxy relay service

I am writing an ASP.net Dashboard application in C#. The application will collect alarm statistics and display them on the dashboard via Ajax(jQuery).
The application could collect the alarm stats cross domain so we chose to set it up as follows:
A standalone Windows Service runs with a constant connection to the Broker(a program that collects stats). Inside the Windows Service we've hosted a WCF service. The windows service will load pass the string of stats into the WCFExternalService.
We then setup an WCF Service hosted in IIS and referenced inside the Client app( this service will act as a relay/proxy service).
Can someone please point me to an article or explain how to setup the bindings/endpoints to connect the proxy service to the external WCF service?
Thanks in advance for any help on this!
Larry
Looks like you have already got most of the structure going. My inputs below:
The WCF proxy (in UI layer) could implement the same service contract as its WCF service counterpart (in Windows service). However, the WCF proxy would be a 'client' of the real WCF service (you need to configure this in Web.config).
Now, enable the WCF proxy to be consumed by jQuery / JavaScript using WebInvoke attribute. [WebInvoke("GET", WebMessageBodyStyle.WrappedRequest, ResponseFormat:=WebMessageFormat.Json)]
Use jQuery $.ajax syntax to consume your WCF proxy. The url should be an equivalent of 'http://myHost/myVirtual/MyProxy.svc/MyMethod' and the data should be a JSON string equivalent of your WCF proxy parameters.
Further explanation on the first point:
This MSDN article explains how to set up a WCF client (to be consumed by your proxy WCF).
Next, you can create a proxy WCF service to consume the WCF client.
The Web.config of your website (which contains the proxy) needs sections for WCF client and WCF proxy.
Hosting does not matter in WCF, so your 'real' service could support any binding (Http, Tcp) based on your requirements and environment

Coarse-Grained WCF Services

I have 2 WCF services now and I want to construct the WCF Service which will use 2 WCF Services(trying to make coarse-grained service).But as you know for making wcf service; create wcf service library and I construct all methods ,write on WCF Service Library.And then I create New Web Site which is WCF Service and I link it to WCF Service Library.
But there exist a problem at that moment; I can't use WCF Service References in the WCF Service Libraries..NET FrameWork can't use wcf service methods in independent WCF Service Library.What is the solution ? The problem is a bit confusing but I think a lot of people are trying to solve this problem ...
You have to move/merge configuration of the referenced WCF services from app.config of your WCF Service Library, to the Web Site's web.config. Everything else should work out of the box.
But there exist a problem at that
moment; I can't use WCF Service
References in the WCF Service
Libraries..NET FrameWork can't use wcf
service methods in independent WCF
Service Library.
?? What do you mean by that?? That doesn't make sense at all. Can you please explain a bit more what you have and what doesn't work??
My "best practice" approach is to have at least two projects for a WCF service:
1) Contracts: all contracts (service, operation, data, fault) go here - only the contracts, nothing else.
2) Service implementation: the actual service code - the code that implements those contracts
Optionally, I might have a third project for hosting the service, not relevant in your case if you have hosting in IIS.
On the client side, I typically also use two projects:
1) ClientProxies which contains all the proxies / service references for others to use
2) Client(s) are the ultimate users of my service - an Winforms App, a WPF app, ASP.NET etc.
I use this approach a lot and I've never had any trouble with not being able to use a service reference or anything, as you say.....

Categories

Resources