WSDL for SOAP - What about REST? - c#

Pretty new to WCF
I was browsing through various WCF Terminologies and seems stuck understanding this.
WSDL is used to describe the web service.
Currently, only SOAP based web services seems to have an associated WSDL while REST based services doesn't seem too.
Why?
Is it possible to generate WSDL for REST too?
Or are there any third party programs to do it ?

WADL is equivalent to WSDL for RESTful services

Since Microsoft .NET does not natively support WADL (WADL is WSDL for REST) providing a specific answer to your question is a bit difficult. That said, if you are interested in discovering more about RESTful services and WADL, you may want to consider experimenting with the open-source soapUI web service test utility (http://www.soapui.org/), which provides support for WADL.

The idea of codifying a RESTful API into a never-changing contract is antithetical to REST. Yes, WADL exists, but its purpose is to try and make REST more like SOAP, and with it destroy the primary benefit of REST: its evolvability.
If you feel like you want to use WADL, just use WSDL/SOAP instead.

You can use swagger.json as definitions for REST services.
you can check their github page for more information.
https://github.com/RSuter/NSwag

Related

web services information and how to integrate in the project

I am new to web services kind of things, wanted to know what are web services and how we can implement that in our asp.net project.
Searched on many sites but couldn't get the exact solution or a basic example of how to use that.
Could anyone please help.
There are many ways of implementing webservices. In .Net probably you want to have a look to:
Web API, if you want HTTP Rest webservices
WCF, if you want to implement SOAP services
In order to take that decision you need to think about the requirements of your services. Who are going to be the clients? Do you need distributed transactions?

how to make a service, SOAP web service in .net?

Please forgive me for this basic and a little theoretical question as I dont know much about web services.
I m not refering WCF service, I am reffering simple service in .net / C#. I want to know how to know is it soap or rest service ?
How we can change this type from Soap to Rest and vice versa ?
Thanks
XML Web Services (aka classic/legacy ASMX web services) should not be used for active development. If you must, there is a nice walkthrough on MSDN for adding Web references in more recent versions of Visual Studio (> 2005).
On the other hand, if your web service is truly Restful then you won't be able to create the equivalent of a service reference to it. You'll need to either use the HttpWebRequest, WebClient, or the new HttpClient from .NET 4.5 (also available from the Rest starter kit which is depreciated as well).
As an alternative if you are looking to implement a client that is able to handle both situations, I would recommend HttpWebRequest to POST to the SOAP (non-WCF) service. The problem with this method is you'll likely have to wrap the request in the SOAP wrapper yourself. Luckily there are examples of doing so on the net that you can at least use as a starting point.
ASMX services are build upon SOAP. REST is simply a HTTP based, You can access(or call) your business resources the way you access the normal URLs.
For ex in products catalog system, by using asmx you create set of functions to add,update,delete products. like addProduct(),updateProduct, etc..
But in REST, you will be having single point of access, like http:\mysystem\prodcuts. To retrieve,add,update,delete products, you will be using respective HTTP verbs (GET,POST,PUT,DELETE) on the same URL.
so,technically it's not possible to convert asmx(SOAP) service to rest...

What is the point in a WSDL with a rest based service?

If REST based web services are as simple as GETing and POSTing to a url and parsing the response wht exactly do we need a wsdl? Whats the point. I understand that when using SOAP based services it is used to construct the SOAP requests and responses but dont really see why visual studio provides me with a wsdl when I create a REST based service...
WSDL is designed to allow clients to discover service capabilities, primarily at design time. REST has the hypermedia constraint that requires that all service capabilities should be discoverable at runtime via the linked representations that they return.
Proper REST services are naturally discoverable therefore there is no need for a WSDL specification in addition.
There is no point in WSDL for REST services created with WCF because WCF supports only WSDL 1.1 (or 1.0) which cannot describe REST seevice. If you try to use WSDL generated for WCF REST service to create a client proxy you will not be able to call the service anyway. Visual studio templates for REST don't expose metadata so you will get useless WSDL only if you add serviceMetada behavior (and possibly also mex endpoint) yourselves.
WSDL 2.0 and WADL supports description of REST services and the point is similar as with SOAP services - describe what you can do with the service but in the REST way.
There's no point. WSDL is just a standardized description of what a service exposes and how can be invoked. You don't need WSDL, but you need some way of documenting what can be done with your service, so that clients know how to invoke it.

Calling a php SOP webservice from c# that does not support wsdl

Can any body have idea how to consume php soap web service that have no support wsdl.
I want to add reference in .Net to generate client but failed.
When i saw in browser with ?wsdl it shows message wsdl is not supported.
Simply said: you can not. WDSL is there for development environments to know how to deal with a web service. Whoever wrote the web serivce made sure (or was ignorant enough to now know) that it is not usable from any tooling support.
You might want to consult the PHP: SOAP Manual and verify that you wrote the PHP webservice correctly.
And you can also look at this example: PHP Webservice and C# / .NET SOAP Clients
You need to configure the SOAP Service to support WSDL
(Web Services Description Language) An
XML-based language for describing Web
services and how to access them.
Otherwise .NET won't know what or how to use it.

Is there a WCF Rest C# Client Generation Tool?

Before I venture down the path of creating one, I was wondering if anyone knows of a utility program which will take the REST Help page of a WCF Rest Service and create the relevant Client for C# consumption.
Similar to what svcutil.exe does for WCF Services or what wsdl.exe did for web services but for WCF REST Services
Kind Regards,
Andrew
EDIT Some more detail:
Please see this link: http://msdn.microsoft.com/en-us/library/dd203052.aspx
In the restful service using the WCF Rest Starter Kit Preview 2, they supply types which will be serialized. But My intention is be able to create clients form the help page which describes schemas. Clients could then be created for C#, JavaScript, ActionScript etc.. shearly as a strongly typed version of the restful service, not a requirement or necessity. It is a program or uitlity I am wondering exists which does this
I think you might be looking for the WebChannelFactory. It can generate a channel class based on a WCF-attributed REST interface.
Well, there will not be any use even if you would like to abstract. ALL Rest services can use HTTP verbs like GET, POST, PUT, DELETE
So, basically what your client can have is only a static class which can accept the end point, network credentials, a name value collection which needs to be passed and the verb to use.
This would be more of a utility class rather than a client.
I don't remember seeing WSDL or some contract based on which we can write clients for the REST services.
I hope you don't spend too much time basing your code on the current help page of a pre-release piece of code. Are you even sure this help page provides all the information you would need to produce clients?
Also, have you seen Prerelease 2 of the WCF REST Starter kit yet? If no, go look. There's new client-side technology in there.
Why would you create clients for a RESTful service? You don't need one - you just need to be able to initial HTTP requests. If you would like to call the same operations via SOAP or some other method then create a new endpoint for the service and a new contract and expose mex for it so that svcutil can consume it.

Categories