Is there a WCF Rest C# Client Generation Tool? - c#

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.

Related

How can I mock another web service?

I have code that calls a web service. We'll say a "3rd party" web service. So I can get the wsdl for this service, in fact I've generated a proxy class using this wsdl.
The requirement that I'm trying to meet is this: Create a web service that LOOKS just like the above mentioned one, but does other stuff. So the web service URL will be changed in a config file/database, to allow switching between the two web services.
What I'm not sure about is how I can use that proxy class that I generated, or some other method, so that the namespacing and data contract look exactly the same. I don't know much about this and these are terms that colleagues have tossed out there. I only need to actually implement one of the web service's methods in my version.
Build site with any technology you know of and return responses that match that service.
Note that if you just need to return static enough responses for occasional testing you can use Fiddler as it allows to return arbitrary responses instead of real once.

WSDL for SOAP - What about REST?

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

SOAPAction and servicestack

don't know if you can help a poor befuddled c# programmer, but here goes. I have a client with a legacy Java Soap app that we need to accept incoming Soap requests from. I have built a solution and tested it and all is well.
When I let the Java app loose on the ASMX file, it fails because I cannot for the life of me get my code to accept the soap action needs to be understood at my end.
The soap action sent is by the Java is:
urn:mycode:uk:gi:dis:supplierenmanager:v02:SupplierManager:AppointManager
Whereas I have used the following against the class that is created when a new web service is added:
<WebService(Namespace:="urn:mycode:uk:gy:dis:suppliermanager:v02:SupplierManager:")>
Then on the method, I have added:
<WebMethod(MessageName:="AppointSupplier")>
This works apart from one little problem. The combination of the above provides the following soap action:
urn:mycode:uk:gi:dis:supplierenmanager:v02:SupplierManager:/AppointManager
As you can see, I am getting an extra forward slash and thus the soap action is rejected.
Does anyone know a work around, or if I am better off using WCF now?
If the answer is USE WCF DUMMY, that is fine and would willing accept that as an answer, but if that IS the case, can someone please point me in the direction of some samples that will explain how to deal with SOAP headers and the dreaded SOAPAction.
Thank you
Can't see a solution to this, but now looking at converting code from ASMX web service to WCF service that consumes soap.
This is because if I create an empty asp.net site and add a wcf service, I can add the following code to the function declaration in the interface code:
<OperationContract
(Action:="urn:mycode:uk:gi:dis:supplierenmanager:v02:SupplierManager:AppointManager")> _
This DOES create the correct SOAPAction.

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...

A RESTfull search service Question

I have a SQL Server (2008) database that contains address details that i want to make available to search as a rest service.
All that needs to be available is the ability to pass an address or part of an address and the service will return the potential candidates, much like yahoo or googles rest services.
My question is, from a high level what is the best approach to take for this?
I am using .net 4 and VS2010 but i have never made a rest service before.
Any links to similar articles or advice on the best approach would be appreciated
I've included a link to a very basic tutorial on making your own restful web service. Publishing web services aren't that difficult especially when no authentication is involved. Essentially you need to define a new class that inherits IHttpHandler interface, implement a couple of methods including the ProcessRequest inside which you can write text into the Response object. You may have to look into the Request object for query parameters (if you need to) and query your db accordingly.
http://www.codeproject.com/KB/aspnet/RestServicesInASPNET2.aspx

Categories