1

I want to build a wcf web service so that the client and the server would be able to transfer files between each other. Do you know how I can achieve this? I think I should turn it into a byte array but I have no idea how to do that. The file is also quite big so I must turn on streamed response.

Dan Short
  • 9,598
  • 2
  • 28
  • 53
user1746708
  • 691
  • 1
  • 8
  • 16

1 Answers1

0

It sounds like you're on the right track. A quick search of the interwebz yielded this link: http://www.codeproject.com/Articles/166763/WCF-Streaming-Upload-Download-Files-Over-HTTP

Your question indicates that you want to send a file from a java client to a WCFd endpoint, but the contents of your question indicate that this should be a bidirectional capability. If this is the case, then you'll need to implement a service endpoint on your client as well. As far as that is concerned, I cannot be of much help, but there are resources out there like this SO question: In-process SOAP service server for Java

As far as practical implementation, I would think that using these two links you should be able to produce some code for your server and client.

As far as reading all bytes of a file, in C# you can use: File.ReadAllBytes It should work as in the following code:

//Read The contents of the file indicated
string fileName = "/path/to/some/file";
//store the binary in a byte array
byte[] buffer = File.ReadAllBytes(fileName);
//do something with those bytes!

Be sure to use the search function in the future: semi-phenomenal, nearly cosmic powered Stack Overflow search function

Community
  • 1
  • 1
Todd Richardson
  • 1,119
  • 1
  • 11
  • 22