【发布时间】:2010-12-13 18:37:21
【问题描述】:
我收到以下错误:
"远程服务器返回错误: (400) 错误请求”
“请求超时”
有时在使用网络服务连接到主机时。如果返回的 XML 为 5 kb,则它工作正常,但如果大小为 450kb 或更大,则显示错误。
以下是我的代码以及驻留在客户端系统中的配置文件。我们无权访问服务器的设置。
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim fileName As String = Server.MapPath("capitaljobs2.xml")
Dim client = New CapitalJobsService.DataServiceClient("WSHttpBinding_IDataService", "http://xyz/webservice.svc")
Dim userAccount = New UserAccount()
'replace here
Dim jobAdList = client.GetProviderJobs(userAccount)
'## Needed only to create XML files - do not ucomment - will overwrite files
'if (jobAdList != null)
' SerialiseJobAds(fileName, jobAdList);
'## Read new ads from Xml file
Dim capitalJobsList = DeserialiseJobdAds(fileName)
UpdateProviderJobsFromXml(client, userAccount, capitalJobsList)
client.Close()
End Sub
Private Shared Function DeserialiseJobdAds(ByVal fileName As String) As CapitalJobsService.CapitalJobsList
Dim capitalJobsList As CapitalJobsService.CapitalJobsList
' Deserialize the data and read it from the instance
If File.Exists(fileName) Then
Dim fs = New FileStream(fileName, FileMode.Open)
Dim reader = XmlDictionaryReader.CreateTextReader(fs, New XmlDictionaryReaderQuotas())
Dim ser2 = New DataContractSerializer(GetType(CapitalJobsList))
capitalJobsList = DirectCast(ser2.ReadObject(reader, True), CapitalJobsList)
reader.Close()
fs.Close()
Return capitalJobsList
End If
Return Nothing
End Function
还有配置文件
<system.web>
<httpRuntime maxRequestLength="524288" />
</system.web>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IDataService" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
<readerQuotas maxDepth="2000000" maxStringContentLength="2000000" maxArrayLength="2000000" maxBytesPerRead="2000000" maxNameTableCharCount="2000000" />
<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
<security mode="None">
<transport clientCredentialType="Windows" proxyCredentialType="None" realm=""/>
<message clientCredentialType="Windows" negotiateServiceCredential="true" establishSecurityContext="true"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://xyz/DataService.svc" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IDataService" contract="CapitalJobsService.IDataService" name="WSHttpBinding_IDataService">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
</client>
</system.serviceModel>
我正在使用“Fiddler”来跟踪它正在读取和终止文件的活动
* FIDDLER:RawDisplay 在 16384 个字符处被截断。右键单击到 禁用截断。 *
但在配置中没有提到数字 16348。
你能确定错误是在客户端还是服务器端?以上设置在客户端。
提前致谢。
【问题讨论】:
-
如果你在每行代码前放四个空格,它就会被格式化,并且你的 XML 不会被 HTML sanitizer 吃掉:)
-
您的帖子格式不正确,请重新格式化。
-
顺便说一句,我可以猜测 Fiddler 错误消息与您的配置无关,而是与 Fiddler 的配置有关。默认情况下,它不会显示超过 16384 个字符,您必须禁用该设置。
-
感谢您的回复。我已经用重新格式化进行了编辑。请。检查发布。
-
我尽我所能来“挽救”这篇文章......我希望我没有破坏任何我不应该破坏的东西......
标签: asp.net