Hi!
I have to send a file to my webservice, but the webservice assumes the file (byte Array) as a base64Binary.
Before the encoding, the byteArrayFile is saved on disk as a regular File. (I'm doing it just for testing)
So, in my Java client for webservice, I'm sending the information this way:
String file = new sun.misc.BASE64Encoder().encode(byteArrayFile);
port.sendFileToWebService(file);
The webservice have to decode the information and save the received file on disk.
[WebMethod]
public string sendFileToWebService(string file)
{
string dirname = HttpContext.Current.Request.PhysicalApplicationPath + "\\Attachments\\";
if (!System.IO.Directory.Exists(dirname))
{
System.IO.Directory.CreateDirectory(dirname);
}
string filename = dirname + "/" + "file.sim";
WebClient myWebClient = new WebClient();
myWebClient.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
byte[] byteArray = null;
byteArray = Convert.FromBase64String(file.Replace("\n", ""));
byte[] responseArray = myWebClient.UploadData(filename, "POST", byteArray);
return "Webservice says OK";
}
The problem is:
The file saved on disk (before encoding) and the file decoded with C# are not equals. I don't know if it's a problem in Java encoding or C# decoding.
Any suggestions, including changing file types or logic process, will always be appreciated.
Thanks in advance!
EDIT - File comparison: