2009-06-23 2 views
3

바이트 배열을 C# 서비스로 보내거나받는 동안 다음과 같은 예외가 발생합니다.XML 판독기를 만들 때 사용되는 XmlDictionaryReaderQuotas 개체의 MaxArrayLength 속성 변경

There was an error deserializing the object of type System.Byte[]. 
The maximum array length quota (16384) has been exceeded while reading XML data. 
This quota may be increased by changing the MaxArrayLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. 
Line 6, position 34838.'. 
Please see InnerException for more details 

내가 이해할 수있는 것은 XmlDictionaryreader가 웹 서비스에서 자동으로 생성된다는 것입니다.

그래서 "MaxArrayLength"속성을 어떻게 변경할 수 있습니까?

public string addFile(string sharePointServer, string documentLibrary, 
          byte[] content, string fileName) 
    { 
     try 
     { 
      SPWeb spWeb = new SPSite(sharePointServer).OpenWeb(); 
      SPFolder spFolder = spWeb.GetFolder(documentLibrary); 
      SPFileCollection spFileCollection = spFolder.Files; 
      SPFile spFile = spFileCollection.Add(fileName, content, true); 
      return spFile.TimeCreated.ToLongDateString() + "::" + spFile.Title; 
     } 
      catch (Exception ex) 
     { 
      throw ex; 
     } 
    } 

파일 < 16킬로바이트이 업로드됩니다

는 구현 코드입니다.

파일> 16kb는 아닙니다.

파일> 10MB는 문제없이 다운로드됩니다.

해당 속성은 어디에 구성되어 있습니까?

답변

7

WCF 서비스입니까? 그렇다면, 당신은이 SO 게시물에 본 바인딩에 maxarraylength을 변경할 수 있습니다

post

P.S.을 파일을 업로드 할 수있는 OOTB Sharepoint 서비스가있는 이유는 무엇입니까? 즉, Lists.asmx처럼이 문서에서 :

article

+0

를 추가 @Colin을 : 그것은 당신이 너무 분명있을 수 있습니다,하지만 난 그것을 얻지 못했습니다. 구성이 http://bit.ly/QMhME 질문에 게시 된 파일에 있다고 말하고 있습니까? 어떤 파일인가. 해당 질문에 대한 대답은 다른 게시물로 리디렉션되어 다운로드로 리디렉션됩니다. 내 문제에 대한 답을 알고 있다면 여기에 게시 하시겠습니까? WCF 서비스입니까? 그렇 겠지. 나는 자바로 서비스를 호출하는 클라이언트이다. 실제로는 ws를 생성하지 않는다. 내가 게시 한 List.asmx를 살펴 보겠습니다. 왜 사용하지 않았습니까? 나는 아무도 그것이 존재한다는 것을 알지 못했을 것이다. – OscarRyz

+0

자바를 사용하고 있습니다. 질문을 분명하게 업데이트하십시오. 내 질문에, 당신은 "구식"C# 웹 서비스, 또는 "새로운"Windows 통신 Foundation "서비스를 호출하는 서비스 의미합니다. 내 대답은 두 번째가 true 인 경우에만 도움이됩니다. 표시되는 예외는 ? C# 또는 자바 PS 이것은 qouta을 변경하는 코드 예제입니다 EndpointAddress를 엔드 포인트 = 새 EndpointAddress를 ("HTTP : // 주소/서비스"); WsHttpBinding과 새로운 = 바인딩 WsHttpBinding과(); XmlDictionaryReaderQuotas readerQuotas = XmlDictionaryReaderQuotas. Max; binding.ReaderQuotas = readerQuotas; – Colin

+0

추 신 : Lists.asmx (http : //urlofsite/_vti_bin/Lists.asmx)는 실제로는 사용할 수있는 방법입니다. – Colin

1

<binding> 요소 내부에 <readerQuotas> 요소를 추가하고 MaxArrayLength 부동산

<bindings> 
    <wsHttpBinding> 
     <binding name ="Your WSHttpBinding Name" sendTimeout="00:05:00" maxReceivedMessageSize="2147483647"> 
      <security mode="None"></security> 
      <readerQuotas maxStringContentLength="134217728" maxArrayLength="2147483647" /> 
      <reliableSession enabled="true"/> 
     </binding> 
    </wsHttpBinding> 
</bindings> 
관련 문제