Can I expose a service with REST & SOAP via WCF? - c#

I want to architecture our software so that we can expose our API logic using WCF (SOAP and REST).
Im confused as to whether I have to use ASMX files if I want to do SOAP services, or whether .svc file can still do SOAP service?

Yes you can. You have to expose a SOAP end-point for your WCF service. This MSDN post has an example.

Your svc file can provide the restful interface you are requesting. You just have to do a little configuring within your web configuration file, and decorate the svc class with the attributes to describe the behavior of our restful url.
here is a great article going over the steps:
http://www.dotnetfunda.com/articles/show/779/simple-5-steps-to-expose-wcf-services-using-rest-style

Related

Add WCF web service to web page

I am a little confused by web services and how they're used. I have created a WCF web service that has an operation contract taking 3 parameters. Then I interrogate our database and return an object matching the data contract. All seems to be good. But how does a third party use our web service? What do I need to provide to them in order for them to use it? Do I need to put a link on my web site? What should that link look like? Thanks!
For third party, you need to share:
Path of Hosted service: it is needed to add service reference.
Information about Service Contract methods: documentation of what exposed operation contracts actually do.
DataContract dll: Only if you are reusing DataContracts.
Some information some times needed to add endpoint if you have to customize default endpoint for client (something like service timeout, packet size etc).
Hope it helps.

Regarding Mex & WSDL issue in WCF

What is the importance of this setting httpGetEnabled="false" or httpGetEnabled="true" what will happen if we set httpGetEnabled="false"
suppose if I want any .Net 2.0 client can consume my wcf service which has been developed by .Net 4.0 then how should i develop the wcf service. once i read that if any client need to consume my wcf service then we need to set httpGetEnabled="true" as a result they can consume ny wcf service through wsdl. things was not ver clear so if possible please in more details how wcf service expose through wsdl.
In wcf mex is also there to expose meta data. So I like to know what is the difference between mex & wsdl?
What mex offer more than wsdl? people said mex is configurable but wsdl is not...What does it mean? need details.
If we search Google to see how wsdl envelope looks like then we get ample of link but I found none for how mex envelope look like searching Google. so please help me to visualize how mex meta data structure look like.
If we remove mex endpoint from service config then how other client can consume my service?
other client can consume my service then through wsdl if yes then how ?
what url I need to enter to have the wsdl of any wcf service ? if `httpGetEnabled="false then wsdl will be possible or not.
Here I asked couple of quetion on mex & wsdl. I am new so bit confused about mex & wsdl usage in wcf.
another question is that what is the usage of soap in wcf & relation.
Invoking the service is totally different than exposing metadata. Basically, a service doesn't have to expose metadata (mex or wsdl) to be called by clients.
Metadata are just exposed to allow easier proxy class generation. This allow developpers to 'Add a service referencee' in VS. WCF provides another way to generate a proxy class : using wsdl.exe with a physical wsdl file.
You can also redistribute your service contract through assemblies and use ChannelFactory.
Exposing metadata is useful on dev, because it allows developpers to re-generate proxy class easily after each modification on the contract (Update Service Reference). On Stage/Prod, it depends on your context : it is generally disabled to "hide" service contract.
About wsdl versus mex, there is another recent answer for this.
If we remove mex endpoint from service config then how other client can consume my service? other client can consume my service then through wsdl if yes then how ?
Your clients can invoke your service only if the have a generated proxy class or your service definition. As I said, they can generate this class using metadata when they want or use a physical wsdl file that you have previously sent.
what url I need to enter to have the wsdl of any wcf service ? if `httpGetEnabled="false then wsdl will be possible or not.
HttpGetEnable allow you to expose metadata through HTTP GET method, usually the service’s address with the suffix of ‘?wsdl'. Simply browse the service url and wcf will generate an help page for you.

What tools/methods are used to consume WCF web services for Android?

I am designing an Android application which is supposed to connect to a server via WCF web service.
I have a WCF web service written in .NET 4.5 and it is a self-hosted web service. It has SOAP endpoint configuration and it is not a very complex service, however it does include some methods which return DTOs (Classes containing lists, other DTOs and value types).
Now the problem I am facing is that I wish to use some sort of tools to consume the web service definition and generate the proxy classes. I have been successful doing this with the help of Eclipse, but the resulting generated code uses alot of external libraries not available within Android.
Now my question is, what are the preferred tools/methods to consume WCF SOAP web services?
I found that using the following tool gave me the best generated code.
https://code.google.com/p/android-ws-client/
I do recommend this tool to anyone looking for consuming a WCF SOAP web service.

How to create a Asmx Client for Wcf Service

I have some clients calling my asmx service and I figure out to change my asmx to a Wcf service.
How can my asmx clients call to my Wcf service without modify the client application?
Maybe just a few changes in the config file...
I can't expect than they compile their applications.
The following article illustrates a detailed guide on how you could achieve that.
You need to support basicHttpBinding in your WCF server and provide new URL to your basicHttpBinding endpoint to callers.
Callers only need to change URL they use.
Everything should happen behind the scene for them.

Adding RESTful capabilities in existing .asmx (SOAP based) webServices

I am having an Existing ASMX webservice in Production. I need to add RESTFul capabilities to the same for Rest Clients.
As per my understanding it must be as simple as adding a HTTPHandler (restversion.ashx) implementing IHTTPHandler and calling Business methods while serializing the return objects to XML or byte Stream. Which will be received and interpreted by REST Clients.
Though, while searching on the similar topics, it is not recommended and Can't be done.
Please suggest me..
I would recommend using WCF Web API. There are several tutorials at the end of this page. As you can see it is pretty easy to build simple RESTful service. There is also built in test client so you can test your REST service using your browser.
Assuming you want to continue your investment in the legacy ASMX technology, you can create a new WCF REST service, and have it call the existing ASMX service as a client, in order to perform its functions.

Categories

Resources