REST and hosting of WCF service - wcf

I am developing a WCF service (VS2010, .NET 4.0). If in the WCF service I utilise REST type functionality (i.e. decorate my methods with WebGet, etc), since REST heavily leverages the HTTP protocol, am I locked into hosting the WCF service as HTTP - i.e. do I have the option to host as net.tcp ?

Short answer - Yes, unless you want to write your own HTTP stack analog.
Is there any particular need in Tcp?

Related

In WCF can I expose webHttpBinding Restfull and NetNamedPipeBinding at the same time which is hosted in IIS

Am creating a WCF service which will be hosted in IIS 7. Can I expose webHttpBinding for Json communication and also netNamedPipeBinding for internal to the system
No, It's not allowed to have two types of protocol on single WCF service in one hosting process on IIS. The reason is that for WebHttpBinding you would need to use AspnetcompatibilityMode which allows WCF to be hosted side by side in Asp.net app domain and allows functionalities like Routing, access to HttpContext.Current.
Other binding types won't be supported with other types of biding if you have Aspnetcompatiblitymode enabled. For more details read the MSDN documentation here.

Consuming WCF service (without metadata) on a non-.net platform

I have created a WCF service and hosted it through self hosting. This service doesn't have any metada published.
First Question
Can I consume it through Visual Studio, Add Service Reference? Hopefully not.
Can I consume it by creating manual proxy, i.e. ChannelFactory<ServiceContract>....?Hopefully yes.
Now in the second scenario, the client must be .Net, right?
So it implies that, to consume a wcf service on a non-.net platform, we have to expose its metadata?
Can't a WCF service without metadata, consume by Ajax client, or say Java client??
There are 3 options to consume a WCF Service:
If the service exposes a WSDL use "add service reference" from VS (or an equivalent from another platform). Note that if you do not want to expose the WSDL you could expose it just temporarly, save the WSDL in a file, and then send it to user in any platform to generate proxy from it. You can turn off the WSDL immediately after you save it. Also note that even if the WSDL is not exposed still you need to protect the web service from unauthorized access.
If this is a .Net client it can compile with the same Service Contract assembly and use ChannelFactory etc.
Any platform can send raw soap message (e.g. XML) to the service. Of course they need to know what is the right format. A WSDL can help but even without it if they have a working sample they can imitate it.
WCF provides REST (Representational State Transfer) support to consume it by non .NET client like JavaScript (AJAX), java, Objective C, web browser, etc...
Basically WCF REST is exposes methods and transferring data over the HTTP protocol and it supports all HTTP operations (GET, POST, PUT, and DELETE). This feature is making it platform independent as well as it doesn’t require metadata exposed.
Please refere below links to get more about WCF REST:
An Introduction To RESTful Services With WCF
WCF REST Programming Model Overview
WCF Rest vs. WCF SOAP
Create RESTful WCF Service API: Step By Step Guide

consuming wcf in .net 2.0 winform

How can we consume WCF service in .Net 2.0 Winform. Please note that we don't have IIS on the client. an example or a sample would be great.
It all depends on how your WCF endpoints are configured.
If you're using SOAP based WCF Services over HTTP, you should be able to simply add a Service Reference from your .NET 2.0 WinForms application and be on your way (which is what I would suggest doing).
If that's not the case, you'll have to provide a little more detail about what you're trying to do with your WCF Services.
You can host your WCF service in a Windows Service as per this article. In that case, it will listen on the HTTP protocol on any port you configure.

WCF client and non-wcf client

Could you please tell what is the difference between a WCF client and a non-WCF client?
When I generate proxy of a WCF service using svcutil and put that in client, what is created - wcf client or non-wcf client?
When should I use WCF client and non-WCF Client?
If you have a WCF service, its services are available to potentially several types of clients - both .NET applications using WCF themselves, or other apps.
Basically, any WCF binding that start with net.... is a .NET specific binding - only other .NET apps with WCF can connect to those services and call their methods.
The bindings with basic.... or ws...... typically are interoperable, e.g. using only industry standards like SOAP and WS-* standards - those can be called from Java, Ruby, PHP - you name it. Any language/system with a SOAP stack can call such a service (provided you get the configuration right on both ends)
The webHttpBinding is another special case - it's exposing it's services over REST - which means anything with a HTTP stack (pretty much every computer system and more and more phones and devices, too) can call its methods.
As long as you are programming your stuff in .NET, always use the WCF client - it's the easiest and the best if it's available. If you need to call your WCF service from a PHP client, of course, then you have to use PHP technology and something that's compatible between the two worlds....

WCF (Param encryption and .NET 1.1 clients)

I'm starting in the WCF world and would like to ask your opinion on something.
I need to implement a service exposing one method that receives a couple of parameters. I want the parameters, submitted from a form in the client to the service, to be sent encrypted in the SOAP message.
The service needs to be accessed from .NET 3.5 clients and also 1.1. It is not possible to install the WCF service via a windows service, it needs to be deployed as a IIS app.
My questions:
- How can the WCF service assure encryption of the input parameters? A certificate in the client or are there any alternatives?
- Is there any problem consuming the WCF service via 1.1 apps, or even other non .NET clients?
- Do you think this scenario is implementable with WCF?
Thank you in advance
There is no way for a .NET 1.1 application to call a WCF service unless that service is exposed through basicHttpBinding. That binding only permits the use of SSL for encryption.
SSL on the web service host.
.NET 1.1 doesn't support automatic encryption, or WS-Security. You can encrypt/decrypt the parameters manually, though.