2009-11-06 181 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

相關問題