Skip to main content

Good day,


I have a web service (normal asmx) which takes as an argument a byte array for a file upload.


When I try to point the Endpoints WebSerivce to this web service the type is generated as a Memo datatype.


How can I change the web service to allow the service instance to pick it up as a file? Is this a supported type of the Endpoints webservice service object?


Please let me know,


Regards,

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


Sorry, I meant to post on this thread:

 

http://community.k2.com/t5/K2-blackpearl/How-to-send-an-array-of-byte-to-a-web-service-thru-a-smart/td-p/66732


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());
}

 


Reply