Silverlight + WCF错误“The remote server returned an error: NotFound.”的解决方法
来源:互联网 发布:wp采集软件 编辑:程序博客网 时间:2024/05/16 07:19
今天在项目中发送数据包到服务器端,WCF返回错误信息:The remote server returned an error: NotFound. 经过排查,通过以下步骤进行了解决。
Silverlight企业级项目中,经常要发送大量数据包到服务器端,而WCF服务本身对数据包进行了限制,最大不能超过65535,而我在项目中尝试发送XML大数据包到服务器端,WCF返回以上错误。
起初考试在客户端尝试重新定义BasicHttpBinding对象
Dim binding As BasicHttpBinding = New BasicHttpBinding()
binding.MaxBufferSize = 2147483647
binding.MaxReceivedMessageSize = 2147483647
binding.MaxBufferSize = 2147483647
binding.MaxReceivedMessageSize = 2147483647
然后考虑修改ServiceReferences.ClientConfig文件,增加Buffer 尺寸。
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IDataService"
maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<security mode="None" />
</binding>
</basicHttpBinding>
</bindings>
但是,WCF仍旧报错。
最后,尝试修改服务器端,在Web.config中添加自定义BasicHttpBinding对象,
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IDataService"
maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647"
maxBufferSize="2147483647">
<readerQuotas
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxDepth="2147483647"
maxNameTableCharCount="2147483647"
maxStringContentLength="2147483647" />
</binding>
</basicHttpBinding>
</bindings>
另外,在ServiceBehaviors中添加maxItemsInObjectGraph属性
<behaviors>
<serviceBehaviors>
<behavior name="TeacherLogic.Net.Web.DataServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</serviceBehaviors>
</behaviors>
添加自定义Binding对象后,在endpoint中引用,就解决了“NotFound”问题了。
<endpoint address="" binding="basicHttpBinding" contract="Myproject.IDataService" bindingConfiguration="BasicHttpBinding_IDataService"/>
在Silverlight官方论坛还有一种说法,因为404 Notfound错误的,还可能因为跨域问题,这个问题比较容易解决,只要在网站根目录下建立一个clientaccesspolicy.xml文件即可。
<?xml version="1.0" encoding="utf-8" ?>
<access-policy>
<cross-domain-access>
<policy>
<allow-from http-request-headers="*">
<domain uri="http://*"/>
</allow-from>
<grant-to>
<resource path="/" include-subpaths="true"/>
</grant-to>
</policy>
</cross-domain-access>
</access-policy>
摘自: http://kevinfan.blog.51cto.com/1037293/293828
- Silverlight + WCF错误“The remote server returned an error: NotFound.”的解决方法
- Silverlight + WCF错误“The remote server returned an error: NotFound.”的解决方法
- Silverlight + WCF错误“The remote server returned an error: NotFound.”的解决方法
- Silverlight调用WebService出现CommunicationException The remote server returned an error: NotFound的一种可能原因
- 关于Silverlight中WebService调用出现CommunicationException The remote server returned an error: NotFound
- sliverlight: The remote server returned an error: NotFound.
- Windows Phone中http请求收到The remote server returned an error: NotFound.
- HttpWebRequest The remote server returned an error: (407) Proxy Authentication
- SharePoint Log - "The remote server returned an error: (409) Conflict."
- The remote server returned an error: (403) Forbidden.
- The remote server returned an error: (415) Cannot process the message because the content type 'text
- svn执行上下文错误 the proxy server returned an error
- svn执行上下文错误 the proxy server returned an error
- The remote server returned an error (415) Cannot process the message
- request 报错The remote server returned an error: (415) Unsupported Media Type.
- The remote server returned an unexpected response: (404) Not Found
- 经验:SQL Server Compact 出现的错误解决方法. There was an error parsing the query
- Silverlight连接WCF--错误"远程服务器返回了错误NotFound”
- 基于mes的车间质量管理系统设计与实现
- 大二了
- 使用gdb、gdbserver在ARM-Linux下进行远程调试
- c++中关于string str="text"+1;编译通过的分析~~~
- 防止java反编译的一些常用方法
- Silverlight + WCF错误“The remote server returned an error: NotFound.”的解决方法
- Axis Web Service开发之旅 (六) --会话(Session)管理
- asterisk 杂事记录
- 揭开Socket编程的面纱
- 关于软件开发中兼容win7注册表的若干思考
- zoj1694_Shredding Company
- WinCE 背光显示bug
- 用Ogre生成天龙八部的lightmap和minimap的简单方法
- 看看幽默的程序员如何写代码...