Web services 如何使用一个参数调用RESTFul web服务;点“;在…内
我开发了一个RESTFul服务,但是当我想传递一个有点的参数时,我遇到了问题。我尝试对URL进行编码,将点替换为%2E,但找不到终点。当我移除圆点时,找到了终点,因此很明显圆点有问题 例如,此请求适用于: 但另一个没有: 请注意“CILINDRO%2015%20KG%2ECODIGAS”参数中的点 任何帮助都将不胜感激 目前,作为一个补丁,我正在发送由管道字符替换的圆点,在服务中,我正在将其替换回圆点,但这是一个非常丑陋的解决方案 编辑: 编辑:这是完整的web.config文件Web services 如何使用一个参数调用RESTFul web服务;点“;在…内,web-services,rest,wcf,url-encoding,Web Services,Rest,Wcf,Url Encoding,我开发了一个RESTFul服务,但是当我想传递一个有点的参数时,我遇到了问题。我尝试对URL进行编码,将点替换为%2E,但找不到终点。当我移除圆点时,找到了终点,因此很明显圆点有问题 例如,此请求适用于: 但另一个没有: 请注意“CILINDRO%2015%20KG%2ECODIGAS”参数中的点 任何帮助都将不胜感激 目前,作为一个补丁,我正在发送由管道字符替换的圆点,在服务中,我正在将其替换回圆点,但这是一个非常丑陋的解决方案 编辑: 编辑:这是完整的web.config文件 <?
<?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="DATA SOURCE=SLLCOSTO;PASSWORD=uni_1915sll;USER ID=PEDIDO"" 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>
埃米特
这是IIS的一个限制。它将点(编码或未编码)视为扩展 尝试添加
<httpRuntime relaxedUrlToFileSystemMapping="true" />
对于web.config您使用的服务器端技术是什么?但是,我认为这是超级库,因为操作甚至没有被调用,因为URL中的点根本不是超级库。您是否使用
WebGet
属性对方法进行了注释,并提供了uri模板?你能发布一些代码吗?我已经在问题正文中添加了它。我担心,但它不起作用。我已将完整的web.config文件添加到问题正文中。您使用的是IIS express还是cassini?它们都没有。。。。它是ASP.NET开发服务器,因为我现在正在开发中。要使上述解决方案正常工作,您需要使用IIS express
<httpRuntime relaxedUrlToFileSystemMapping="true" />