REST WCF的WSDL

3
我已经通过在web.config中指定WebGET和WebHttpBinding来创建了一个C# REST WCF。该服务通过IE可以正常工作。我的wsdl如下所示,其中包含wsdl中的soap。由于这是REST,所以wsdl中不应该存在soap。
  <?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">

在上面的WSDL中,由于这是HTTP协议,为什么SOAP内容会出现在REST服务中?
谢谢, Vinoth Khanna.S

3
REST没有WSDL......不太确定你在看什么......另外,REST服务没有任何SOAP内容。 - marc_s
你没有发布完整的WSDL... - Donal Fellows
是的,我没有发布完整的WSDL。那么当我在我的服务后面加上“?wsdl”时,为什么它会显示WSDL呢? - VKh
嗨...我刚刚创建了一个REST服务,就像我创建WCF一样。在3.5中创建REST WCF时,我应该遵循其他的方式吗? - VKh
2个回答

3

WCF无法描述REST服务。REST服务可以通过WADL或WSDL 2.0进行描述,但是WCF不支持这些描述语言。


0
如上所述,REST 在 WCF 中没有 WSDL 的概念,只有 SOAP。如果 ?wsdl 的 URL 可用,则可能在您的配置中定义了“mex”(元数据交换)端点,该端点提供 WSDL。如果已经添加了 WCF 服务,则通常会默认添加此功能。如果不计划使用 SOAP,则可以将其删除。它通常是这样的:
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />

顺便提一下,可以通过以下详细说明的方式,让WCF同时提供SOAP和REST服务:REST / SOAP endpoints for a WCF service


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接