After creating a wcf service how do I tell whether its restful or soap from the wsdl?

The service can be both REST and SOAP, in a way that a WCF service can have multiple endpoints including a mix of both SOAP and REST. On the WSDL, the SOAP endpoints will show up in the wsdl:definitions/wsdl:service/wsdl:port element; the REST endpoints will not. So if you only have one endpoint in the service, if there is a wsdl:port entry in the WSDL, then it's a SOAP endpoint; otherwise it's REST You can run the code below and look at the wsdl to see that it only shows up one wsdl:port element, for the SOAP endpoint public class StackOverflow_6414181 { ServiceContract public interface ITest { OperationContract WebGet string Echo(string text); } public class Service : ITest { public string Echo(string text) { return text; } } public static void Test() { string baseAddress = "http://" + Environment.

MachineName + ":8000/Service"; ServiceHost host = new ServiceHost(typeof(Service), new Uri(baseAddress)); host.Description.Behaviors. Add(new ServiceMetadataBehavior { HttpGetEnabled = true }); host. AddServiceEndpoint(typeof(ITest), new BasicHttpBinding(), "soap"); host.

AddServiceEndpoint(typeof(ITest), new WebHttpBinding(), "rest").Behaviors. Add(new WebHttpBehavior()); host.Open(); Console. WriteLine("Host opened"); Console.

Write("Press ENTER to close the host"); Console.ReadLine(); host.Close(); } }.

The service can be both REST and SOAP, in a way that a WCF service can have multiple endpoints, including a mix of both SOAP and REST. On the WSDL, the SOAP endpoints will show up in the wsdl:definitions/wsdl:service/wsdl:port element; the REST endpoints will not. So if you only have one endpoint in the service, if there is a wsdl:port entry in the WSDL, then it's a SOAP endpoint; otherwise it's REST.

You can run the code below and look at the wsdl to see that it only shows up one wsdl:port element, for the SOAP endpoint. Public class StackOverflow_6414181 { ServiceContract public interface ITest { OperationContract WebGet string Echo(string text); } public class Service : ITest { public string Echo(string text) { return text; } } public static void Test() { string baseAddress = "http://" + Environment. MachineName + ":8000/Service"; ServiceHost host = new ServiceHost(typeof(Service), new Uri(baseAddress)); host.Description.Behaviors.

Add(new ServiceMetadataBehavior { HttpGetEnabled = true }); host. AddServiceEndpoint(typeof(ITest), new BasicHttpBinding(), "soap"); host. AddServiceEndpoint(typeof(ITest), new WebHttpBinding(), "rest").Behaviors.

Add(new WebHttpBehavior()); host.Open(); Console. WriteLine("Host opened"); Console. Write("Press ENTER to close the host"); Console.ReadLine(); host.Close(); } }.

Cheers carlos, I am having another chat about why the wsdl is still showing up when I remove the SOAP binding. Should it? – Exitos Jun 20 at 16:51 I'm assuming that you meant that you removed the SOAP endpoint, not only the binding Well, you enabled it (), so it will create a WSDL document for your service.It's not too common, but one reason why one would want to have a WSDL for a REST-only service is that the WSDL contains the data contract definitions (which will be generated if you use svcutil).

The service contract, however, will likely not be correct (since things such as UriTemplate / WebGet / BodyStyle / etc don't show up in the WSDL). – carlosfigueira Jun 20 at 16:56.

If you have a WSDL - it's a SOAP service. REST doesn't have WSDL. REST has a similar concept called WADL - Web Application Description Language (WADL specification as PDF) - but that's not nearly as well established and widely used as WSDL for SOAP.

Sorry when I create a REST WCF service with c# it dos actually create a wsdl. Its there on the screen. – Exitos Jun 20 at 16:13 okay here it is: – Exitos Jun 20 at 16:35 When I right click on the service and 'View in Browser' it shows me a wsdl.. – Exitos Jun 20 at 16:38 1 @Pete2k - defines a SOAP endpoint, and so you have a WSDL.

Mark is correct that if you have a WSDL, then WCF either thinks it is a SOAP service, or it has been told to publish the SOAP WSDL (by having a MEX endpoint). – rally25rs Jun 20 at 16:39 1 @Pete2k - if you have "taken the binding for the REST endpoint out" as you stated, then that means you are left with the SOAP endpoint, so you would still have a WSDL. Did you mean the opposite; that you removed the SOAP endpoint, leaving only the REST one in the config?

– rally25rs Jun 20 at 16:53.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions