Return byte [] in WCF service

Is it good to return byte [] in a WCF service that will be called by many applications.

below is the code

public byte[] GetDoc(string docParam) { byte[] doc; doc = GenerateDoc(docParam); } 

thanks

+6
wcf
source share
3 answers

It’s good practice to extend the general code to a convenient method so that many callers can name this convenient method. This is independent of the type of return. If callers will need to be manipulated byte[] , then this can be convenient and eliminate redundant code.

By the way, regarding the code you posted, is this real code or just an example? If this is real code:

  • It will not compile because it does not return byte[] .
  • If you should have called return doc; as the last line, why is GenerateDoc() inside GetDoc() ? GetDoc() really does not provide any real benefits.
+2
source share

Of course, you can return byte[] , and WCF allows you to do this using MTOM encoding.

If the size of the binary buffer is large, you can use WCF stream conversion . In this case, you return the Stream data type and read from that Stream on the client side.

+2
source share

It is used when you want to transfer a binary buffer, as well as perform large data transfers using MTOM encoding (set in the binding settings). How to perform a large data transfer found here .

0
source share

All Articles