Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / March 2005

Tip: Looking for answers? Try searching our database.

returning a picture from a webservice

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ohad Young - 08 Mar 2005 09:53 GMT
Hi,

I was wondering if it is possible to code a webservice that returns a
picture?
If so, How?

Thanks in advance, Ohad
Glenn - 08 Mar 2005 10:55 GMT
Perhaps try converting the image to a base64Encoded string in the web
service?

Not sure if this is the best mechanism, but I've used it before to encode
binary data at it seems to work.

HTH

Glenn

> Hi,
>
[quoted text clipped - 3 lines]
>
> Thanks in advance, Ohad
Denny Britz - 08 Mar 2005 11:59 GMT
You can use WSE + DIME Attachments:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wse/html/6d65ea
5f-eb78-41bc-8964-df1271d9d5a7.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwse/html/wsed
ime.asp


I think that's a better way to attach data than using
base64encoded strings..

Denny

> Perhaps try converting the image to a base64Encoded string in the web
> service?
[quoted text clipped - 13 lines]
>>
>>Thanks in advance, Ohad
Glenn - 08 Mar 2005 14:44 GMT
Thanks for the info, I'll take a look.

Glenn
> You can use WSE + DIME Attachments:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wse/html/6d
65ea5f-eb78-41bc-8964-df1271d9d5a7.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwse/html/
wsedime.asp

> I think that's a better way to attach data than using
> base64encoded strings..
[quoted text clipped - 18 lines]
> >>
> >>Thanks in advance, Ohad
Raj Tripathi - 08 Mar 2005 12:51 GMT
If its a small bitmap
1. Convert it to a byte array.
2. Send over wire.
3. Desearialize from a byte array.

If its a big bitmap use WSE Attachments.
Current implementation of WSE uses DIME (which would be replaced in the
future by MTOM)

> Hi,
>
[quoted text clipped - 3 lines]
>
> Thanks in advance, Ohad
Ohad Young - 08 Mar 2005 14:02 GMT
Hi all,

Thank you all for your quick response.
Since the pictures are small bitmaps, the most suitable option is the
byte array conversion.
Where can I find a code example for it?

Thanks again, Ohad
Raj Tripathi - 08 Mar 2005 18:05 GMT
On Server:
[WebMethod]
public byte[] GetBitmap()
{
   Bitmap bitmap = new Bitmap(@"c:\picture.bmp");
   MemoryStream stream = new MemoryStream();
   BinaryFormatter formatter = new BinaryFormatter();
   formatter.Serialize(stream, bitmap);
   return stream.ToArray();
}

On Client:
Bitmap GetBitmap()
{
  localhost.BitmapService service = new BitmapService();
  byte[] rawBitmap = service.GetBitmap();
  BinaryFormatter formatter = new BinaryFormatter();
  MemoryStream stream = new MemoryStream(rawBitmap);
  return (Bitmap) formatter.Deserialize(stream);
}

Raj Tripathi
Ohad Young - 09 Mar 2005 07:27 GMT
Hi Raj,

Thanks for the code example.
I'll try it :)

Ohad

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.