.net 创建的svc服务始终是SOAP

.net 创建的svc服务始终是SOAP,.net,wcf,rest,.net,Wcf,Rest,我正在尝试创建REST Web服务: Print.svc: <%@ ServiceHost Language="C#" Debug="true" Service="WcfService1.Print" CodeBehind="Print.svc.cs" %> You have created a service. To test this service, you will need to create a client and use it to call the servi

我正在尝试创建REST Web服务:

Print.svc:

 <%@ ServiceHost Language="C#" Debug="true" Service="WcfService1.Print" CodeBehind="Print.svc.cs" %>
You have created a service.

To test this service, you will need to create a client and use it to call the service. You can do this     using the svcutil.exe tool from the command line with the following syntax:

svcutil.exe http://localhost:8415/Print.svc?wsdl

You can also access the service description as a single file:
http://localhost:8415/Print.svc?singleWsdl
Print.cs

public string Printer(string id)
{
    return "hola" + id;
}
和web配置:

    <?xml version="1.0"?>
     <configuration>

      <appSettings>
        <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
      </appSettings>
      <system.web>
        <compilation debug="true" targetFramework="4.5" />
        <httpRuntime targetFramework="4.5"/>
      </system.web>
      <system.serviceModel>
        <services>
         <service name="WcfService1.Print" behaviorConfiguration="ServiceBehaviour">
            <endpoint address="" binding="webHttpBinding" contract="WcfService1.IPrint" behaviorConfiguration="web"/>
         </service>
        </services>
     <behaviors>
      <serviceBehaviors>
        <behavior name="ServiceBehaviour">         
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>          
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="web">
          <webHttp/>
        </behavior>                
      </endpointBehaviors>
    </behaviors>
    <protocolMapping>
        <add binding="basicHttpsBinding" scheme="https" />
    </protocolMapping>    
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
    <directoryBrowse enabled="true"/>
  </system.webServer>

</configuration>
所以这是一个SOAP Web服务!!我要它休息!
这里的问题是什么?

我犯了一个小错误:

   [WebInvoke(Method="GET",
        ResponseFormat= WebMessageFormat.Json,
        BodyStyle=WebMessageBodyStyle.Wrapped,
        UriTemplate="print/{id}")]
UriTemplate应该是“Printer/{id}”


无论如何,我不明白为什么我可以对rest Web服务执行wsdl???

rest没有wsdl的概念——这是SOAP的最大优点之一。REST目前没有可比性——我知道,问题是我能够对REST服务执行wsdl。
   [WebInvoke(Method="GET",
        ResponseFormat= WebMessageFormat.Json,
        BodyStyle=WebMessageBodyStyle.Wrapped,
        UriTemplate="print/{id}")]