2012-04-09 3 views
2

iOS의 Sharepoint 용 문서 라이브러리에 문서를 업로드하려고하는데 제한된 성공을 거두고 있습니다.저급 웹 서비스를 사용하여 Sharepoint Library에 문서 업로드

나는이 비누 요청을 사용하여, 적어도 대상 문서 라이브러리에 표시 내 문서를 얻을 수 Copy.CopyIntoItems을 사용하고 있습니다 :

<?xml version="1.0" encoding="utf-8"?> 
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
    xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 
    <soap:Body> 
    <CopyIntoItems xmlns="http://schemas.microsoft.com/sharepoint/soap/"> 
     <SourceUrl>[server url]</SourceUrl> 
     <DestinationUrls><string>[server url]</string></DestinationUrls> 
     <Fields></Fields> 
     <Stream>[base 64 encoded string]</Stream> 
    </CopyIntoItems> 
    </soap:Body> 
</soap:Envelope> 

이 나 적어도 내 문서 내 라이브러리에 표시하도록 가져옵니다. 그러나 응답은 나에게 GUID와 같은 메타 데이터를 제공하지 않으므로 결국 관리하기가 더 어려워집니다. 또한 브라우저에서 항목을 볼 때 "소스 항목보기"와 같은 작업에 대한 추가 옵션과 "이 항목이 다른 위치에서 복사되었습니다 ..."라는 추가 프롬프트를 삭제할 때 추가 옵션이 있습니다. SharePoint를 사용하는 대부분 Bob이기 때문에 혼동을 일으킬뿐입니다. 이상적으로는 브라우저에서 문서 라이브러리를 통해 직접 업로드 할 때와 마찬가지로 문서의 동작이 동일하게 나타납니다. 투명도가 높을수록 좋습니다.

내가 온라인으로 본 다른 일반적인 해결책은 Lists.UpdateListItems과 Lists.AddAttachment의 조합을 사용하는 것이 었습니다. Lists.UpdateListItems 제대로 작동하고 새 항목을 만들었습니다. (GUID와 같은 메타 데이터를 다시 제공하므로 좋았습니다. 적어도 은 양식 업로드 문서와 동일하게 나타납니다). 그러나 Lists.AddAttachment는 나를 위해 작동하지 않습니다. AddAttachment이 SOAP 요청을 사용합니다 (GUID는 UpdateListItems에 새로 추가 된 항목의 GUID입니다) :

<?xml version="1.0" ?> 
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
    <soap:Body> 
    <AddAttachment xmlns="http://schemas.microsoft.com/sharepoint/soap/"> 
     <listName>Test</listName> 
     <listItemID>{1F214D95-B92B-4E10-8B96-4B04DC6DA9B6}</listItemID> 
     <fileName>screenshot.png</fileName> 
     <attachment>[base 64 string]</attachment> 
    </AddAttachment> 
    </soap:Body> 
</soap:Envelope> 

나는 다음과 같은 응답을 얻을 :

<?xml version="1.0" ?> 
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
    <soap:Body> 
    <soap:Fault> 
     <faultcode> 
     soap:Server 
     </faultcode> 
     <faultstring> 
     Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown. 
     </faultstring> 
     <detail> 
     <errorstring xmlns="http://schemas.microsoft.com/sharepoint/soap/"> 
      Input string was not in a correct format. 
     </errorstring> 
     </detail> 
    </soap:Fault> 
    </soap:Body> 
</soap:Envelope> 

어떤 아이디어? 나는 어딘가에 잘못된 길을 가고 있다고 확신한다. 나는 어디 있는지 모른다. 감사!

+0

GUID 인 updateListItems에서 ows_UniqueId를 사용하는 대신 listItemId에 대한 다음 시도로 ows_ID (이 경우에는 44)를 사용하도록 설정합니다. 이번에는 나의 반응이 좀 더 보편적 인 "가치가 예상 범위에 들지 않음"이라고 응답했습니다. Soooo ... 아직도 작동하지 않는다. 그러나 나는 이것이 더 가깝다고 생각한다? – cscott530

답변

1

오늘 아침에 작동했습니다. 결국 가장 간단한 접근 방식을 사용하게되었는데, 솔직히 마이크로 소프트 API로는 작동하지 않을 것이라고 생각했습니다.

NSString *fullPath = @"https://site/library/folders/document.txt"; 
NSURL *url = [NSURL URLWithString: fullPath]; 
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; 
request.HTTPMethod = @"PUT"; 
request.HTTPBody = [NSData {documentData}]; 

//this is the authentication Cookie acquired in a previous request. 
[request addValue:cookie forHTTPHeaderField:@"Cookie"]; 
[NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil]; 

키가 PUT을 메서드로 사용하는 것으로 보입니다.

제한된 메타 데이터가 반환되는 문제가 있지만 SharePoint 웹 사이트를 통해 직접 업로드하는 것과 비슷하므로 문제가되지 않는다는 점에 유의해야합니다. 아마도 기존 문서를 다운로드하거나 업데이트할지 여부를 결정하는 논리를 다시 고쳐야 할 것입니다.

관련 문제