我使用的是Windows 7,IIS 7.5,.NET 4.5.
(对于Windows 8,IIS 8.5,.NET 4.5,这是有效的).
使用URL执行GET请求:
http://my.host/api1/MyEntity('%2311282')
Run Code Online (Sandbox Code Playgroud)
问题是当它到达服务器端代码时,%23 char已经被解码为'#'而Uri对象认为它是一个片段char.Win8机器接收到char%23未触及的URL.
试图:
1)使用此配置设置
<httpRuntime targetFramework="4.5" relaxedUrlToFileSystemMapping="true" />
Run Code Online (Sandbox Code Playgroud)
2)在URL的末尾添加"/"
http://my.host/api1/MyEntity('%2311282')/
Run Code Online (Sandbox Code Playgroud)
3)卸载url rewrite 2模块 - 并重新安装.还尝试在web.config中为模块注释重写部分.
为什么我要复制Windows 8的行为 - 不解码URL.有任何想法吗?
我试图在Android 2.1上使用Java客户端使用其余的WCF服务.它适用于小响应.当我试图通过获得1000+ char响应reader.read(缓冲区)无法读取所有字符时进一步推动.这导致脚本的最后一行返回:JsonException未终止的字符串,字符为8193"{plate,...
我的android设备开始在模拟器android明星得到它之前得到这个错误(字符1194而不是8193).谁知道怎么得到完整的消息?
客户代码:
HttpGet request = new HttpGet(SERVICE_URI + "/GetPlates");
request.setHeader("Accept", "application/json");
request.setHeader("Content-type", "application/json");
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpResponse response = httpClient.execute(request);
HttpEntity responseEntity = response.getEntity();
char[] buffer = new char[(int)responseEntity.getContentLength()];
InputStream stream = responseEntity.getContent();
InputStreamReader reader = new InputStreamReader(stream);
reader.read(buffer);
stream.close();
JSONArray plates = new JSONArray(new String(buffer));
Run Code Online (Sandbox Code Playgroud)
服务器配置:
<webHttpBinding>
<binding name="big_webHttpBinding" maxReceivedMessageSize="4097152" maxBufferSize="4097152" maxBufferPoolSize="4097152">
<readerQuotas maxStringContentLength="4097152" maxArrayLength="4097152" maxBytesPerRead="4097152" maxNameTableCharCount="4097152" maxDepth="4097152"/>
</binding>
</webHttpBinding>
Run Code Online (Sandbox Code Playgroud)