How to support XMLRPC bindings in WCF .Net 4 web service without tinyblogger example - wcf

Darin Dimitrov answered a question about supporting XMLRPC interface (bindings) under a WCF .net web service. In his response, he explained to add references to Microsoft.Samples.XmlRpc and TinyBlogEngine.
Why is the TinyBlogEngine engine needed?
How can I take a working .net 4 WCF web service and add support for XMLRPC without making it a blog application?

Why is the TinyBlogEngine engine needed?
TinyBlogEngine simply contains the WCF web service code which you could replace with any implementation you like (blog or whatever). This could be an existing web service you already have. Microsoft.Samples.XmlRpc is what enables a XML RPC binding to an existing WCF service. You just need to have this XmlRpcEndpointBehaviorExtension I've shown in the post if you want to be able to configure the RPC binding via web.config.

Related

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

How to publish binding details of the WCF web service to clients on the internet?

I want to host my WCF web service in the public domain (on internet) so that any client application (java, .net etc.) can consume it.
The WSDL will give details of the service (what it offers etc.). But,
How to inform the binding details to the clients?
I want to know how do we inform binding details to the outside world when you are on internet and you do not know who the client will be. WSDL gives the details of the service; similarly what mechanism is there to inform the binding that's required to communicate with the service.
Do I need to stick to some specific bindings when I want to publish my web service over internet where anybody can consume it?
svcutil or Visual Studio (using svcutil in background) will understand binding specification provided by metadata exchange binding (look here)
it wouldn't. If You want Your web service to by used by technologies other than .NET You shouldn't use .NET specific implementations.
basicHttpBinding works with soap 1.1. wsHttpBinding with soap 1.2 and WS-*. You shouldn't use other bindings if you want your web service to be interoperable.

Adding an HTTP RPC Service using webHttpBinding for an Existing SOAP Service implemented with WCF?

I've been told that adding an HTTP RPC web service given an existing SOAP web service implemented with WCF is as simple as adding a webHttpBinding and a couple of attributes.
I'd be grateful if someone could show how to implement such an HTTP RPC web service using webHttpBinding given an existing SOAP web service that is based on WCF. It would be super helpful if the answer could show all the code for both services and even more helpful if the example is self-contained so that someone could install for testing without having to know anything about either. FYI, while I have programmed on the .NET stack it's been ~5 years and today all my work is on LAMP so I'm just not familiar enough with the latest generation .NET stack or it's current runtime environments.
My specific use-case is a set of two (2) services where one responds with an AuthToken and then a second service where I pass the AuthToken and Username, Password and another bit of information and the response back is a user object with attributes like 'first_name', 'last_name', etc. Ideally I'd be able to access those same services via two different URLs and the responses I would get back would be in JSON format.
Note I'm looking for an example to be installed by someone else who programs on the .NET stack but isn't highly motivated to do won't much extra work. I'm trying to get an HTTP-based web service I can use without having to add a SOAP client to the existing PHP framework I am using and I think if I could get a concise example of how to add such an HTTP RPC web service the .NET programmer might be happily willing to add the HTTP RPC web service for my needs. FYI, the web service in question was developed specifically for this use case and is not part of a standard set of SOAP services documented for and in use by lots of other developers.

Wrap the Application Service in ASMX or expose directly via WCF?

I have an application service layer (which all return serializable viewmodels). Some of these app services need to be callable via AJAX by client code in the Web UI. I'm currently wrapping them in ASMX files that do nothing but dictate the response format as JSON delegate each call to the application service class with the same signature.
Is it advisable to try to save a few lines of code by exposing the appropriate application service classes as WCF services? Can someone point me to an example? Any potential pitfalls for usage in WebForms client code?
Microsoft now considers ASMX services to be "legacy technology". You should not use them for any new development. They have been completely replaced by WCF. For instance, see the top of this article: http://msdn.microsoft.com/en-us/library/bb885203.aspx:
This topic is specific to a legacy
technology. XML Web services and XML
Web service clients should now be
created using Windows Communication
Foundation .

Exposing meta data for a WCF 4.0 Rest Template Service

Probably missing something very basic. I created a WCF 4.0 Rest Service. It works no problems when I'm hitting the url from a browser and I'm getting back what I want.
But now I want to use that service from a client mvc application (it will also be used by other non .net platforms which is why it's a rest service in the first place).
Problem is how do I get a service reference to it so I can start to use it in my c# code? With the new minimal WCF .net 4 config approach and no interface for the service contract, I don't know how to specify a mex endpoint. Ultimately I don't want a mex endpoint in production, just during development. I would love to be able to specify that all my services (around 10 in one application) have endpoints with one tiny piece of config that vs2010 .config transformations just rips out when I publish.
Stop. REST service doesn't use metadata. Metadata (Mex endpoint) are only for SOAP services because WSDL 1.1 (the only version supported by WCF) is able to describe only SOAP service. WADL or WSDL 2.0 is able to describe REST service but non of them is currently supported by WCF.
REST service is consumed by using WebRequest directly or by building ChannelFactory on top of shared contracts. Both methods are described here. Other method is to use HttpClient from REST Starter kit (former API). The problem with Starter kit is that it has never reached RTM (it was replaced by WCF 4). Instead of metadata endpoint WCF 4 REST service offers help page where all operation are described. When using WCF 4 REST template the help page should be already turned on - just add /help sufix to address of your service. Here is another article about building REST clients.