Sharepoint soap request MTOM

422 views Asked by At

So we have a requirement to upload file to sharepoint server using iOS client . We are able to upload file size till 40kb but the problem is the file data we are passing is in Base64 encoding,and it fails for file size more than 40kb because we cannot pass large data in soap message,so we tried different approaches possible and mentioned on web . These are the ways we tried out

and we are left with only sending data using MTOM .

After lots of experiments and search I think MTOM is a way to upload data using soap . We are using CopyIntoItems sharepoint service for upload .

Soap request looks like

   <"xmlns:soap12=\"http://schemas.xmlsoap.org/soap/envelope/\">\n"
                                     "<soap12:Body>\n"
                                     "<CopyIntoItems xmlns=\"http://schemas.microsoft.com/sharepoint/soap/\">\n"
                                     "<SourceUrl>%@</SourceUrl>\n"
                                     "<DestinationUrls>\n"
                                     "<string>%@</string>\n"
                                     "</DestinationUrls>\n"
                                     "<Fields>\n"
                                     "%@"
                                     "</Fields>\n"
                                     "<Stream>MY_FILE_DATA</Stream>\n"
                                     "</CopyIntoItems>\n"
                                     "</soap12:Body>\n"
                                     "</soap12:Envelope>\n"

Now the problem is how do we format this soap request in the way MTOM accepts,because CopyIntoItems may not work in some other format.

Few samples of MTOM which i looked into

http://pic.dhe.ibm.com/infocenter/wasinfo/v6r1/index.jsp?topic=/com.ibm.websphere.wsfep.multiplatform.doc/info/ae/ae/cwbs_soapmtom.html

http://cxf.apache.org/docs/mtom.html

Any help would be much appreciated..Thanks..!!

1

There are 1 answers

4
Stefano Altieri On

What about using HTTP post and developing an Http handler to store posted data?

It is quite easy to setup an http handler in Sharepoint (MSDN) and in the Process request method you can use query string to get the information you need. Say you create an Upload.ashx handler.

public void ProcessRequest(HttpContext context)
{
  var targetList = context.Request["targetList"];
  var targetFileName = context.Request["targetFn"];
  // Get the stream to content
  var stream = context.Request.GetBufferedInputStream();
  // Save the file somewhere
}

From the client you do an HTTP post to http://server/_layouts/15/Upload.ashx?targetList=myFiles&...