开发者

Sending a file over web service from java to .net

开发者 https://www.devze.com 2022-12-23 20:15 出处:网络
I have built .NET 1.1 Web Service which should accept files and save them. Here is the code of the webmethod:

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 colleague of mine tries to send me a file from a JAVA client I don't get the actual 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.


Sounds like the bug is in the java -- or at least the java is not sending what the .net service expects. Can we see the java code?

0

精彩评论

暂无评论...
验证码 换一张
取 消