Sending a file over web service from java to .net

Posted by Goran on Stack Overflow See other posts from Stack Overflow or by Goran
Published on 2010-03-24T15:18:20Z Indexed on 2010/03/24 15:23 UTC
Read the original article Hit count: 336

Filed under:
|
|
|
|

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.

© Stack Overflow or respective owner

Related posts about web-services

Related posts about .NET