Migrating binary data through a SOAP web service?

I have a web service that returns a binary array of an object. Is there an easier way to convey this using SOAP or should it be contained in XML? It works, but I had to increase the send and receive buffer to a large value. How much is too much?

Porting binary code to XML as an array seems really inefficient, but I see no way to add a binary attachment using .NET.

+6
c # soap binary web-services
source share
3 answers

How is the array? You mean what you send

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

etc.? If so, you can, of course, improve it by first sorting through an array of bytes into a hexadecimal string, for example.

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

This is the most common way to send images, etc. through SOAP. However, even then you are right to question him. You really should look at other, more RESTful, IMHO transfer protocols.

+4
source share

In the HTTP protocol, you send one message of type mime type / xml, which contains a SOAP message. But HTTP allows you to send multiple messages, such as email, composed by message and attachments. This is called "Soap with attachments" http://en.wikipedia.org/wiki/SOAP_with_Attachments This is done with the mime type "multipart / related".

Check what about WCF http://msdn.microsoft.com/en-us/library/ms733742.aspx

+2
source share

Well, indeed, you should not send binary information using webservice. Doing this kind of invalidates the point of using the web service, compatibility. Ideally, you would serialize your object as xml. However, if you send information that is essentially binary, say, an image, then you can definitely put this in the payload of your SOAP message. How much information really depends on how long you will wait and how fast your network is. I do not believe that there is a real limit to the size of the information you can send. If this is really a lot (50 megabytes + seems like an arbitrarily large number), you can consider alternative transport protocols, such as streaming through a socket.

+1
source share

All Articles