How to use WCF Stream service in Java client?

I am developing a java client to use the WCF service below. Since the WCF service uses Stream technology, I also hope to use stream technology in java client code to reduce memory usage. Can anybody give me advice on how to write it? Thanks.

namespace TmpWcfStream { [MessageContract] public class InputMessage { [MessageHeader(MustUnderstand = true)] public string TranName { get; set; } [MessageBodyMember(Order=1)] public Stream FileData { get; set; } } [MessageContract] public class OutputMessage { [MessageBodyMember(Order = 100)] public bool Success { get; set; } [MessageBodyMember(Order = 200)] public string ErrorMsg { get; set; } } } namespace TmpWcfStream { public class UploadDataSvc : UploadSvcContract { private const int bufferLen = 4096; public OutputMessage UploadData(InputMessage msg) { OutputMessage outputMsg = new OutputMessage { ErrorMsg = string.Empty, Success = true }; try { Stream inputStream = msg.FileData; String filePath = @"C:\tmp\output.txt"; using (FileStream targetStream = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.None)) { byte[] buffer = new byte[bufferLen]; int count = 0; while ((count = inputStream.Read(buffer, 0, bufferLen)) > 0) { targetStream.Write(buffer, 0, count); } } inputStream.Close(); } catch(Exception e) { outputMsg.Success = false; outputMsg.ErrorMsg = e.ToString(); } return outputMsg; } } 
+8
java stream interop wcf
source share

No one has answered this question yet.

See related questions:

3799
How do I read / convert an InputStream to a string in Java?
3324
How to generate random integers in a specific range in Java?
3073
How to efficiently iterate over each entry on a Java map?
2853
How to convert String to int in Java?
2171
How to determine if an array contains a specific value in Java?
2108
How can I name one constructor from another in Java?
1915
How to declare and initialize an array in Java?
1818
How to get enum value from string value in Java?
1571
How to avoid Java code in JSP files?
1541
How to break a string in Java

All Articles