2011-06-29 33 views
1

我有一個soap web服務,其中響應正文包含一些轉義xml。 所以在響應的身體,我有:NetDispatcherFaultException返回轉義xml時出錯

<soap:Body> 
    <GetServiceResponse xmlns="http://www.abc.com/x/"> 
     <GetServiceResult> 
      <Result> 
       <Value>&amp;lt;/param&amp;gt; etc....</Value> 
      </Result> 
     </GetServiceResult> 
    </GetServiceResponse> 
</soap:Body> 

在我的客戶我得到一個異常NetDispatcherFaultException「格式化拋出一個異常,而試圖反序列化」。我使用的客戶端上下面的代碼:

var binding = new BasicHttpBinding(); 
var address = new EndpointAddress("http://localhost:2948/ReportingService.asmx"); 
ReportingServiceSoap service = new ReportingServiceSoapClient(binding, address); 
var response = service.GetConfig(request); <-- Exception raised on call 

如果我更換了一些字符串值(沒有逃脫XML),然後客戶端不引發異常轉義文本。

任何想法在哪裏看?

JD

回答

3

打開異常,我發現這是一個ReadQuotas問題。另外,我正在測試mSpec的客戶端接口,這意味着app.config沒有被正確的ReadQuotas值讀取。所以在代碼我有:

var binding = new BasicHttpBinding(); 
binding.ReaderQuotas.MaxStringContentLength = 2147483647; 
binding.ReaderQuotas.MaxArrayLength = 2147483647; 
binding.ReaderQuotas.MaxDepth = 2147483647; 
binding.ReaderQuotas.MaxNameTableCharCount = 2147483647; 
binding.ReaderQuotas.MaxBytesPerRead = 2147483647; 

這解決了這個問題。