MVC 4 web api that consumes WCF Services - wcf

I would like to know if any of you knows how to consume wcf services from MVC 4 web API.
I know it might sound crazy but I have to have them both in the same solution, that's why I need to know if anyone here can provide me with some tutorial or some more detailed explanation.
Thanks in advance.

generate your proxy class using your wcf service contract
call the proxy class from your web api to access the wcf service.
or make use of Castle Windsor WCF facility and let it create the client on the fly for you.
http://docs.castleproject.org/Default.aspx?Page=WCF-Integration-Facility&NS=Windsor&AspxAutoDetectCookieSupport=1

Related

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 Service in Windows Form Application

I'm newbie in WCF. I have some questions need to be answered.
Can I use WCF to make a simple chat application from a client to a client (via WCF Service) ?
I have tried follow many examples, And i got a problem. I don't think that IIS need to be installed when i using WCF Selft Hosted, right ?
Sorry about my English !
You don't need IIS for self-hosted WCF services. Look at the ServiceHost class.
Yes, you can make a chat application (client to client) using a service "in the middle". The clients would have to register with the service and then a callback contract should do the job.

Create WCF Json/RESTful service client proxy

here is my question: Is there any tool to generate one service client proxy when the service is Rest/Json? the service is WCF, and one of the clients is WPF and i need this in order to create the tests with similar code than I test the classic Soap WCF services.
If not What is the best way to achieve this?
Thanks in advance
No, there isn't simply because there is no metadata with RESTful protocols such as you get the WSDL from SOAP.
If the service is WCF, you can use the svcutil.exe util to create a client even if you're using JSON or REST as the binding.
This thread has information on it:
Client configuration to consume WCF JSON web service

using wcf or odata for data entry in wp7

Does anyone have a simple data entry example which involves WCF (Odata ) and WP7?
Thanks
Here are two good places to start:
Introduction to WCF Data service and
ODATA
OData and WCF Data
Services
Once you have the service itself running, you would access it in the WP7 application the same way you access any other WCF service.
Note that there is a OData Client Library for Windows Phone 7. You might also want to read this article for some additional info.

Can I add ony specific WCF endpoints to a .NET 2.0 project as web references?

I'm developing a .NET 2.0 client application that needs to connect to a WCF service. I add a web reference to a basicHttpBinding WCF service that we've developed and VS creates the proxy class and the config paraphenalia which is fine. The problem is that I only want to use a small fraction of the methods that the WCF service implements and not carry around the extra implementations that the client app doesn't need.
I was thinking of creating a different basicHttpBinding endpoint and put the methods there. Is there a way for only one endpoint of a WCF service to be referenced by a .NET 2.0 project?
Regards,
Frank
When you add a web reference to a service, you always get all the service methods. It's the service (implementation) that defines the scope of what ends up in the WSDL.
The only option to limit the scope of the method your client generates would be to create a second WCF service on the backend, which only implements those few methods that you want in your client - just having a second endpoint won't really help.