Hi Tom,
I use a service like that:
<%@ WebService Language="C#" Class="Manage_Document" %>
using System.Configuration;
using System;
using System.Xml;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.IO;
using Hss.Com.WebServices.ExceptionsHandler;
[WebService(Namespace = "http://here.is.your.namespeace")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Manage_Document : System.Web.Services.WebService {
protected string _file_path =
"C:\\Inetpub\\wwwroot\\Hss.Com.WebServices\\Pictur es\\";
[WebMethod]
public bool SaveDocument(Byte[] docbinaryarray, string docname) {
try {
string strdocPath;
strdocPath = _file_path + docname;
FileStream objfilestream = new FileStream(strdocPath,
FileMode.Create, FileAccess.ReadWrite);
objfilestream.Write(docbinaryarray, 0,
docbinaryarray.Length);
objfilestream.Close();
} catch(Exception e) {
SoapExceptionManager mger = new
SoapExceptionManager(Namespaces.WebService);
mger.SetException(e);
SoapException se = new SoapException("Fault occured",
SoapException.ClientFaultCode, Context.Request.Url.AbsoluteUri,
mger.GetExceptionNode());
throw se;
}
return true;
}
[WebMethod]
public int GetDocumentLen(string DocumentName) {
string strdocPath;
strdocPath = _file_path + DocumentName;
int len;
try {
FileStream objfilestream = new FileStream(strdocPath,
FileMode.Open, FileAccess.Read);
len = (int)objfilestream.Length;
objfilestream.Close();
} catch(Exception e) {
SoapExceptionManager mger = new
SoapExceptionManager(Namespaces.WebService);
mger.SetException(e);
SoapException se = new SoapException("Fault occured",
SoapException.ClientFaultCode, Context.Request.Url.AbsoluteUri,
mger.GetExceptionNode());
throw se;
}
return len;
}
[WebMethod]
public Byte[] GetDocument(string DocumentName) {
string strdocPath;
strdocPath = _file_path + DocumentName;
Byte[] documentcontents;
try {
FileStream objfilestream = new FileStream(strdocPath,
FileMode.Open, FileAccess.Read);
int len = (int)objfilestream.Length;
documentcontents = new Byte[len];
objfilestream.Read(documentcontents, 0, len);
objfilestream.Close();
} catch(Exception e) {
SoapExceptionManager mger = new
SoapExceptionManager(Namespaces.WebService);
mger.SetException(e);
SoapException se = new SoapException("Fault occured",
SoapException.ClientFaultCode, Context.Request.Url.AbsoluteUri,
mger.GetExceptionNode());
throw se;
}
return documentcontents;
}
}
I found the base of this code somewhere online but there was no licence
on it, feel free to use and modify it at your will. The Soap Exceptions
Handler is home made, but I can give that as well if anybody needs it
;)
I hope this help.
Best regards,
Pierre