What is the advantage of using Web API in wpf? - wcf

I need to calling our C# Methods from another server to perform some Action. I use C# in both servers. One is our Service Application, another one is a WPF application where I consume my Service.
Prefer I use a WCF or WebAPI service for Service Application?
Most People prefer to use Web Api, but web doesn't expose metadata for creating proxy by service.
which one is simple and better choose?

You may use either WCF or WebAPI, if multiple platforms (Mobile, Web, Other Service) are going to interact with your service, then I would recommend Web API, otherwise you may use WCF. Similar discussion has already happened in another question, please refer this link, hope this will be useful
Getting a web service and using android to consume them?

Related

Use both WCF service and Web Api in same Service fabric reliable services

I haven't had much luck finding a way of using the WCFCommunicationListener as well as HttpListner(OwinCommunicationListner) inside same Reliable service. I Want to use two different listeners one that provide the Soap functionality that I can achieve using WCFCommunicationListener and other will simple Web Api consumption that what pretty much OwinCommunicationListner provides. I don't want to use the WcfCommunicationListener for my REST functionalities, I want to consume my REST apis as Web Api.
I will run two of them on two separated services. Using Docker for WCF and Owin for Web API.
If the problem you have is trying to share code then just have a shared library outside of the two services.
An sample on WCF on Docker here https://blogs.msdn.microsoft.com/webdev/2017/02/20/lets-try-wcf-self-hosted-services-in-a-container/

Calling ServiceStack Service from WCF

I work in a company that is only using WCF and i am trying to introduce service stack. Now i understand we are better off using the service stackclients that wcf clients but for some of our stuff and to keep people happy that will not always be possible. Can anyone provide a basic example of a ServiceStack service that can be added as a client into a VS2012 project using the add service reference inside visual studio as you normally do for a WCF service? Basically is there a way to make ServiceStack seem like a WCF service to people that don't know about ServiceStack?
If i can show this i think i can convince my company to make the switch but if not it will be difficult as everything else is WCF based. We are already using the ServiceStack clients to hook into other online websites so it seems a good time to try to convince them to move to the service stack services and clients as long as they feel they can fall back to the WCF client if needed.
Provided you adhere to the SOAP guidelines and limitations in ServiceStack you should be able to add a Service Reference by pointing the client to the ServiceStack wsdl at /soap12, e.g:
http://servicestackbaseurl/soap12
You can also find a link to the soap 1.1/1.2 wsdl (and XSDs) on ServiceStack's /metadata page.

WCF authentication service via Json

I have built a web service (WCF) as part of our company product, to support mobile devicies. The service is exposed via SOAP and is consumed by Android and Windows Phone 7 clients. Now we are spreading and need to add support for iPhone clients and those lazy iPhone developers are complaing, that they won't use SOAP, because its terrible, microsoftish, bloatware and there is no sufficient framework for that, etc etc and JSON ftw!
As it is WCF it was easy to create json api for this web service (new interface and little changes in web.config, love WCF!), the only problem is that I am using the built-in WCF Authentication service for authorization and this service is of course exposed via SOAP and I didnĀ“t find a way to make it REST with json. So is there a way to somehow make it RESTful and consume/respond json?
My actual plan is to make another auth service, that will internally just call the existing WCF one via SOAP, but I don't like this workaround. I assume that, if there is not a way to make the WCF one RESTfull, later or sooner, I end up writing the auth service, which in my opinon will not be that hard.

wcf and web service compatiblity

I have a web service that is used by many different clients using many different languages.
I want to switch it to wcf to take advantage of the many different endpoints.
However what has been stopping me is that I am afraid that the clients will have to use a special sdk to connect (if they are using java or php or some other language) that is different then the sdk they use to connect to the existing web service.
Is this true? Or is connecting to WCF the exact same as it is for web services in other languages.
The project I am currently working on has multiple WCF configurations, some are using the default SOAP implementation, and some are using a POX (plain-old-xml) style message.
So the short answer is 'yes' you can configure WCF in such a way to work with just about anything.
However, be warned that as soon as you step outside the default little box that WCF has set up for you, it gets pretty complicated. You end up with a lot of custom message parsing and security handling if you go to a POX message format. Its easier if you stick with SOAP though.
As for needing a 'special SDK' you won't. You can communicate with WCF with simple HTTP POST messages if needed.
I have clients that are using VB.NET apps (using SOAP) and Java apps (using POX) to hit my WCF services.
A basicHttpBinding endpoint in WCF is exactly a standard SOAP endpoint, and your Java or PHP clients will not have to change in any way.

When is it appropriate to use WCF over webclient or httpwebrequest?

I'm looking to understand when to use a WCF services instead of just using webclient or httpwebrequest. I guess I'm also looking to understand the difference between the design patterns that would be appropriate for both.
Are you talking about when to create a WCF service yourself (over web service), or when to consume an existing web service using WCF instead of .NET 2.0 ASMX clients?
As for creating a WCF service yourself:
Gives you a lot more options in terms of hosting (in an app, Windows Service, IIS, WAS)
Gives you a lot more security options
Gives you a lot more protocol options (besides just HTTP, you can also use WS-*, TCP, Named Pipes, MSMQ and more)
Allows you to write your service once, and expose it on multiple end-points with different protocols at the same time
As for using WCF to talk to an existing HTTP (ASMX) web service - I don't see a whole lot of massive benefits, except WCF uses more configuration over code, and it can be good to standardize on one way of doing things, if you already use other WCF services, anyway.
Marc
I'm currently using WCF for most of the things that I would use WebClient or HttpWebRequest/HttpWebResponse in the past. While there definitely is overhead for learing how to make calls to web methods using WCF, the extensibility of WCF and the abstraction it provides makes it a MUCH better candidate for these types of calls.
I've already used it to make calls to Akismet and RPX pretty easily.
To get started, I'd look at the section of the MSDN documentation titled "WCF Web Programming Object Model", located at:
http://msdn.microsoft.com/en-us/library/bb412204.aspx