WSDL for REST WCF

I've created a REST WCF in C# by specifying WebGET and WebHttpBinding in web.config. The service works fine through IE. My wsdl starts as below and it has soap in wsdl. Since this is REST, should'nt the soap be present in wsdl.

WSDL :

  <?xml version="1.0" encoding="utf-8" ?> 
 <wsdl:definitions name="ServiceImp" targetNamespace="http://tempuri.org/"    
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
    xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" 
    xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" 
    xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" 
    xmlns:tns="http://tempuri.org/" 
    xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" 
    xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" 
    xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
    xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" 
    xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" 
    xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" 
    xmlns:wsa10="http://www.w3.org/2005/08/addressing" 
    xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex">

In the above wsdl, Since this is HTTP, why is the soap content coming in REST service?

Thanks, Vinoth Khanna.S


WCF is not able to describe REST service. REST service can be described by WADL or WSDL 2.0 but WCF doesn't support any of these description languages.


As stated above, REST has no concept of a WSDL in WCF, only SOAP. If the URL for ?wsdl works, then you probably have a 'mex' (Metadata Exchange) endpoint defined in your configuration, which is what serves up the WSDL. This is usually added by default if you add a WCF service through the VisualStudio wizards. If it is there, it can be removed if you don't plan on using SOAP. It will usually look something like this:

<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />

On a side-note; it is possible to have WCF serve up the same services as both SOAP and REST, as detailed here: REST / SOAP endpoints for a WCF service

链接地址: http://www.djcxy.com/p/71388.html

上一篇: 基于RESTful vs基于SOAP的Web服务?

下一篇: REST WCF的WSDL