I managed to solve this with the help from Samuel at K2.
He advised that SmartObjects handle files with an XML structure containing the filename and the content as a Base64 string.
I then changed my smartobject property to be of the "File" type and then changed my web service to accept this property as string.
In my web service method I then converted it to XML and then converted the content from Base64 to a byte array and saved it to the back-end system.
Using this work-around I was able to submit files using this smartobject.
I hope this will help someone else who is struggling with the same thing.
Hi, Johan.
First of all thank you for posting here.
Сould you post some example your solution? I would like to reproduce the same web service.
Did you use this with smartforms?
Hi,
I'm having the same issue as the OP. I am trying to call an external web service that I can't modify and it requires a file passed in as a byte array.
There doesn't seem to be a resolution to this on this thread. Has anyone found a way around this?
Regards
Phil
Try something like below:
private void GetFileFromXML(out bytee] fileContent, out string fileName, string attachment)
{
fileContent = null;
fileName = null;
var xDocument = XDocument.Parse(attachment);
var file = (from x in xDocument.Descendants("file")
select new
{
FileName = x.Element("name").Value,
FileContent = x.Element("content").Value
}).FirstOrDefault();
fileName = file.FileName;
fileContent = Convert.FromBase64String(file.FileContent.ToString());
}