Sending a file over web service from java to .net
- by Goran
Hello,
I have built .NET 1.1 Web Service which should accept files and save them.
Here is the code of the webmethod:
[WebMethod]
public bool SaveDocument(Byte[] docbinaryarray, string docname)
{
string dirPath = @"C:\Temp\WSTEST\";
if(!Directory.Exists(dirPath))
{
Directory.CreateDirectory(dirPath);
}
string filePath = dirPath + docname;
FileStream objfilestream = new FileStream(filePath, FileMode.Create, FileAccess.ReadWrite);
objfilestream.Write(docbinaryarray, 0, docbinaryarray.Length);
objfilestream.Close();
return true;
}
When I make a client in .NET with reference to this Web service everything goes great, but when a college of mine tries to send me a file from a JAVA client I don't get the actuall file. All I get is byte array with only one element.
Definition of byte array for file, in WSDL looks like this:
<s:element minOccurs="0" maxOccurs="1" name="docbinaryarray" type="s:base64Binary" />
He sends me base64binary and fails every time. All I get is Byte array with only one element inside.