Does PUT and DELETE return error 401 in a WCF Restful service?

0

POST and GET requests work in the same web service. But no PUT and DELETE, I have placed the authentication as "None" but it still does not work.

The interface is as follows:

    [OperationContract]
    [WebInvoke(Method = "PUT", RequestFormat = WebMessageFormat.Json,
        ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare,
        UriTemplate = "/ModificarEvento/{idEvento}/{fechayHoraDeEnvio}/{fechayHoraDeLlegada}/{fechayHoraDeSalida}/{causaEvento}/{observacion}/{asistenciaPolicial}/{supervisionExterna}/{idTipoEvento}/{idEstadoEvento}/{idCliente}/{idPersona}/{idSupervisor}/{idOperador}")]
    int ModificarEvento(string idEvento, string fechayHoraDeEnvio, string fechayHoraDeLlegada, string fechayHoraDeSalida, string causaEvento, string observacion, string asistenciaPolicial, string supervisionExterna, string idTipoEvento, string idEstadoEvento, string idCliente, string idPersona, string idSupervisor, string idOperador);

    [OperationContract]
    [WebInvoke(Method = "GET", RequestFormat = WebMessageFormat.Json,
         ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare,
         UriTemplate = "/ListarUltimosEventos/{aliasUsuario}/{descripcionEstadoEvento}")]
    List<EventoWCF> ListarUltimosEventos(string aliasUsuario, string descripcionEstadoEvento);

The web.config is found as follows:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --></configSections>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
 <authentication mode= "None" />
 <authorization>
  <allow users="*"/>
 </authorization>
 <compilation debug="true" targetFramework="4.5.2" />
 <httpRuntime targetFramework="4.5.2" />
 </system.web>
<system.serviceModel>
<services>
  <service  name="ServicioWCF.AplicacionEscritorio">
    <endpoint address="" binding="webHttpBinding"
             contract="ServicioWCF.IAplicacionEscritorio" behaviorConfiguration="restBehavior">
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
  </service>
  <service  name="ServicioWCF.AplicacionMovil" behaviorConfiguration="ServicioWCFAplicacionMovil">
    <endpoint address="" binding="webHttpBinding"
             contract="ServicioWCF.IAplicacionMovil" behaviorConfiguration="restBehavior">
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
  </service>
</services>
 <behaviors>
  <endpointBehaviors>
    <behavior name="restBehavior">
      <webHttp />
    </behavior>
  </endpointBehaviors>
  <serviceBehaviors>
    <behavior name="ServicioWCFAplicacionEscritorio">
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />
      <useRequestHeadersForMetadataAddress />
    </behavior>
    <behavior name="">
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="false" />
    </behavior>
    <behavior name="ServicioWCFAplicacionMovil">
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />
      <useRequestHeadersForMetadataAddress />
    </behavior>
  </serviceBehaviors>

</behaviors>
<protocolMapping>
  <add binding="webHttpBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="false" />
</system.serviceModel>
<system.webServer>
 <handlers>
   <add name=".svc" verb="*" path="*.svc"
 type="System.ServiceModel.Activation.ServiceHttpHandlerFactory, System.ServiceModel.Activation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
 </handlers>
 <modules runAllManagedModulesForAllRequests="true">
 </modules> 
 <!--
    Para examinar el directorio raíz de la aplicación web durante la depuración, establezca el valor siguiente en true.
    Establézcalo en false antes de la implementación para evitar revelar información sobre la carpeta de aplicación web.
  -->
 <directoryBrowse enabled="true" />
</system.webServer>
<entityFramework>
  <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
 <providers>
   <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
 </providers>
 </entityFramework>
<connectionStrings>
 <add name="DBPrototipoSeguridadEntities" connectionString="metadata=res://*/BDDPrototipoSeguridadEF.csdl|res://*/BDDPrototipoSeguridadEF.ssdl|res://*/BDDPrototipoSeguridadEF.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=SERVER\SQLEXPRESS;initial catalog=PrototipoSeguridad;user id=sa;password=Cadena_02021971;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
 </connectionStrings></configuration>

The result of consuming the PUT request comes out as follows:

    
asked by Daniel Cadena 30.10.2018 в 16:55
source

0 answers