tags:

views:

191

answers:

2

I have a webservice that returns the binary array of an object. Is there an easier way to transfer this with SOAP or does it need to be contained in XML? It's working, but I had to increase the send and receive buffer to a large value. How much is too much?

Transferring binary in XML as an array seems really inefficient, but I can't see any way to add a binary attachment using .NET.

A: 

Well really you shouldn't be sending binary information with a webservice. Doing so sort of invalidates the point of using a webservice, compatibility. Ideally you would serialize your object as xml. However if you're sending information which is inherently binary, say an image, then you can for sure put that in the payload of your SOAP message. How much information is really a function of how long you wish to wait and how fast your network is. I don't believe there is any actual limit on the size of the information you can send. If it is truly a lot (50 meg+ seems like an arbitrarily large number) then you might wish to consider alternative transport protocols like streaming it over a socket.

stimms
It's possible I don't understand the best practice to transfer information from my web-based database to my application. Using SOAP, I can use LINQ on the web-side and it easily binds to objects in my application. Is there an easier way to do this? The object is converted into a binary array to store it more effieciently in the database. As XML, its just too large.
Jason
A: 

As an array? Do you mean that you are sending

<byte>8</byte>
<byte>127</byte>

etc? If so then you can certainly improve on it by converting the byte array into a hex string beforehand, eg.

<codedArray>087F09AFBD.....</codedArray>

This is the most common approach for sending images, etc, via SOAP. However, even then you are correct to question it. You should really be looking at other, more RESTful transfer protocols, IMHO.

pdr
Yes, I think that's how it's encoded. Converting it to hex is a great solution.
Jason