How to call a RESTFul web service with a parameter that has a "dot" inside

1k views Asked by At

I developed a RESTFul service but I am having problems when I want to pass a parameter that has a dot in it. I tried encoding the URL, replacing the dot by %2E, but the end point is not found. When I remove the dot, the end point is found, so it is obvious that something is wrong with the dot.

for example, this request works:

http://localhost:9999/SvcLipigas.svc/AlmacenaPedido/229188562/16122016/2030/123456/CILINDRO%2015%20KGCODIGAS/2/14000/15/19122016/1514/19122016/1000

But this other one does not:

http://localhost:9999/SvcLipigas.svc/AlmacenaPedido/229188562/16122016/2030/123456/CILINDRO%2015%20KG%2ECODIGAS/2/14000/15/19122016/1514/19122016/1000

Notice the dot in the "CILINDRO%2015%20KG%2ECODIGAS" parameter.

Any help will be appreciated.

Currently, as a patch, I am sending the dot replaced by a pipe character, and in the service, I am replacing it back to the dot, but this is a very ugly solution.

EDIT:

[OperationContract]
[WebInvoke(Method = "GET",
    ResponseFormat = WebMessageFormat.Json,
    BodyStyle = WebMessageBodyStyle.Wrapped,
    UriTemplate = "AlmacenaPedido/{telefono}/{fechaPedido}/{horaPedido}/{codigoInterno}/{descripcionProducto}/{cantidadProducto}/{valorUnitario}/{kilosProducto}/{fechaEntrega}/{horaEntrega}/{fechaDespacho}/{horaDespacho}")]
int AlmacenaPedido(string telefono, string fechaPedido, string horaPedido, string codigoInterno, string descripcionProducto,
                   string cantidadProducto, string valorUnitario, string kilosProducto, string fechaEntrega, string horaEntrega,
                   string fechaDespacho, string horaDespacho);

EDIT: This is the full web.config file

<?xml version="1.0" encoding="utf-8"?>
<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=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
      <section name="WS_PedidoCliente.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    </sectionGroup>
  </configSections>
  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" relaxedUrlToFileSystemMapping="true" />
  </system.web>
  <system.serviceModel>
  <services>
    <service name="WS_PedidoCliente.SvcLipigas" behaviorConfiguration="serviceBehavior">
      <endpoint address=""
                binding="webHttpBinding"
                contract="WS_PedidoCliente.ISvcLipigas"
                bindingNamespace="http://ws.lipigas.cl"
                behaviorConfiguration="web"></endpoint>
          </service>
   </services>    
    <behaviors>
      <serviceBehaviors>
        <behavior name="serviceBehavior">
          <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
          <serviceMetadata httpGetEnabled="true" />
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="web">
          <webHttp />
        </behavior>
      </endpointBehaviors>    
    </behaviors>
    <protocolMapping>
      <add scheme="http" binding="webHttpBinding"/>
    </protocolMapping>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
    <!--
        To browse web app root directory during debugging, set the value below to true.
        Set to false before deployment to avoid disclosing web app folder information.
      -->
    <directoryBrowse enabled="true" />
  </system.webServer>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="v12.0" />
      </parameters>
    </defaultConnectionFactory>
  </entityFramework>
  <connectionStrings>
    <add name="LipigasEntities" connectionString="metadata=res://*/Model.Lipigas.csdl|res://*/Model.Lipigas.ssdl|res://*/Model.Lipigas.msl;provider=Oracle.DataAccess.Client;provider connection string=&quot;DATA SOURCE=SLLCOSTO;PASSWORD=uni_1915sll;USER ID=PEDIDO&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>
  <applicationSettings>
    <WS_PedidoCliente.Properties.Settings>
      <setting name="Usuario" serializeAs="String">
        <value>EMDITEC</value>
      </setting>
    </WS_PedidoCliente.Properties.Settings>
  </applicationSettings>
</configuration>
1

There are 1 answers

4
Alex On

This is a limitation of IIS.
It is treating the dot (encoded or not) as an extension.

Try adding

<httpRuntime relaxedUrlToFileSystemMapping="true" />

to the web.config