pistacchio
pistacchio

Reputation: 58923

Webservice: BLOB field

In retrieving data from a Oracle database that contains BLOB fields (Office's .doc files etc), do I have to do something particular to send it via web services?

It is sent like a string and I'm trying to convert the string into an array of bytes and write it to a file to recreate, client-side, the .doc file.

What is the correct approach?

Upvotes: 1

Views: 1336

Answers (2)

Jeff
Jeff

Reputation: 5983

You need to base64 encode the byte stream.

Upvotes: 1

Marc Gravell
Marc Gravell

Reputation: 1063754

It isn't clear from the question, but it sounds like you have the data from the database, and now need to expose it on a web-service. In terms of SOAP etc, this can be as simple as either returning a byte[], or exposing a byte[] on a DTO. If the field is large, you may want to consider MTOM (WSE3) and/or web compression.

So: how does Oracle expose the BLOB to you? If it isn't a byte[], is it perhaps something like LINQ's Binary class, which provides encapsulated access to the data (ToArray() in this case). If it is exposing a string, I would guess that it is base-64 encoded; you could try running Convert.FromBase64String.

Upvotes: 2

Related Questions