2009-11-06 183 views
1

我收到以下错误。如果返回的XML是5 kb,那么它工作正常,但如果大小为450kb或更高,则显示错误。远程服务器返回错误:(400)错误的请求

下面是我的代码以及驻留在客户端系统上的配置文件。我们无法访问服务器的设置。

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: RawDisplay truncated at 16384 characters. Right-click to disable truncation. *

文件,但在配置数量16348不随时随地提到

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

在此先感谢。

+0

如果你把四个空格每一行代码之前,它就会被格式化为这样的,你的XML不会受到HTML吃掉消毒剂:) – 2009-11-06 09:56:09

+0

您的文章格式不正确,请重新格式化。 – tuergeist 2009-11-06 09:56:19

+1

顺便说一句,我可以猜想,提琴手错误消息是不相关的你的配置,但小提琴的配置。默认情况下,它不会显示超过16384个字符,您必须禁用该设置。 – 2009-11-06 09:57:53

回答

0

也许你可以提高通话的超时时间,比如建议在此线程 Setting Timeout Value For .NET Web Service

+0

感谢您的回复,但不知道在哪里做更改,因为我只控制客户端系统而不是主机,因为它远程放置。 – pravakar 2009-11-07 04:24:43

相关问题