远程服务器返回错误:(400)错误请求

时间:2009-11-06 09:35:22

标签: asp.net

我收到以下错误:

  

“远程服务器返回错误:   (400)错误请求“

     

“请求超时”

有时使用Web服务连接到主机时。如果返回的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.

你能弄清楚错误是在客户端还是服务器端?上面的设置在客户端。

提前致谢。

1 个答案:

答案 0 :(得分:0)

也许你可以在这个帖子中增加调用的超时时间 Setting Timeout Value For .NET Web Service