c# - Sharepoint custom client. Read word document via MS-FSSHTTP -


i working on case, company uses web service proxy data exchanges using web services, control data , processes exchanged external partners.

when partner wants open document in word, web service call sharepoint (cellstorage.svc/cellstorageservice) intercepted proxy. ms-fsshttp call.

the response returned sharepoint server of type multipart/related, application/xop+xml.

this mime document, containing soap response in 1 part (text/xml) , content of document in mime (application/octet-stream).

by proxying response can binary content, decompress binary data, fail read word document.

if content of soap message described in ms documentation, there nothing binary part.

we managed read it, failed open word document. exception saying content invalid. main part missing. letting wondering if openxml doc get.

i'd know if have idea of binary content made of?

the content type is:

content-type: multipart/related; type="application/xop+xml"; boundary="urn:uuid:a192024b-547a-584b-a56c-b05f25c22fdf"; start="<1c830af4-214f-1c4b-8a71-6269053e3161@tempuri.org>"; start-info="text/xml; charset=utf-8" 

the returned content is:

--uuid:acf0b1de-4e59-4304-ba6e-23a7a4e2a9cc+id=1 content-id: <http://tempuri.org/0> content-transfer-encoding: 8bit content-type: application/xop+xml;charset=utf-8;type="text/xml"  <s:envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:body> <responseversion version="2" minorversion="3"  xmlns="http://schemas.microsoft.com/sharepoint/soap/"/><responsecollection  weburl="  ...  ></subresponse></response></responsecollection></s:body></s:envelope>  --uuid:acf0b1de-4e59-4304-ba6e-23a7a4e2a9cc+id=1 content-id: <http://tempuri.org/1/636403683925268534> content-transfer-encoding: binary content-type: application/octet-stream ... here comes binary 

we try read content of word document this:

       if (url.contains("cellstorageservice"))         {             memorystream ms = new memorystream(bytes);              string headerresponse = "mime-version: 1.0\r\n" + contenttype + "\r\n";;              string full = headerresponse + content + txt;      byte[] fullbytes = system.text.encoding.utf8.getbytes(full);     // read mime message             mimemessage message = mimemessage.load(new memorystream(fullbytes));              var iter = new mimeiterator(message);             while (iter.movenext())             {                 var multipart = iter.parent multipart;                 var part = iter.current mimepart;                 if (part != null)                 {                     contenttype contenttype = part.contenttype;                     if (contenttype.tostring().contains("application/octet-stream"))                     {                         using (var memory = new memorystream())                         {                             part.contentobject.writeto(memory);                              // content compressed                             memorystream decompressedstream = new memorystream();                              using (gzipstream decompressionstream = new gzipstream(memory, compressionmode.decompress))                             {                                 decompressionstream.copyto(decompressedstream);                                 console.writeline("decompressed");                             }                              // here exception: documentformat.openxml.packaging.openxmlpackageexception: specified package invalid. main part missing                              using (wordprocessingdocument worddoc = wordprocessingdocument.open(decompressedstream, true))                             {                                 var body = worddoc.maindocumentpart.document.body;                                 foreach (var text in body.descendants<documentformat.openxml.wordprocessing.text>())                                 {                                     parsetext(text.text);                                     onaudit(text.text);                                 }                             }                         }                     }                 }             } 

stack trace is

documentformat.openxml.packaging.openxmlpackageexception unhandled user code hresult=-2146233088 message=the specified package invalid. main part missing. source=documentformat.openxml  stacktrace:    à documentformat.openxml.packaging.openxmlpackage.load()    à documentformat.openxml.packaging.openxmlpackage.opencore(stream stream, boolean readwritemode)    à documentformat.openxml.packaging.wordprocessingdocument.open(stream stream, boolean iseditable, opensettings opensettings)    à documentformat.openxml.packaging.wordprocessingdocument.open(stream stream, boolean iseditable) 

innerexception:

do have idea of binary content? , how access docx?

many thanks

gilles


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -