Click to See Complete Forum and Search --> : binary data through web service
Jhd.Honza
Jan 4th, 2002, 03:28 PM
How can I return for example a picture (or any other binary file) by WebMethod function?
Thanks
Cander
Jan 4th, 2002, 03:43 PM
hmm good question
Perhaps create a GDI Graphics object(dont know the namespace off the top of my head) that the Function can return
<Webmethod()>Public Function myImage() As Graphics
End Function
Do some searching for GDI+ to find info on loading an Image to the Graphics object and whatever namespaces needed
IO namespaces/classes might be able to be used for other files..
Cant be 100% sure on this though.
Jhd.Honza
Jan 6th, 2002, 06:36 AM
OK, I have tried this ;) :
1) Declare function as System.Drawing.Image
2) Declare any function with parameter of System.Drawing.Image type
3) Declare function as object, returning bounded System.Drawing.Image
:mad: First two failed during preparing the page, with exception System.Drawing.Image cannot be serialized because it doesn't have default public constructor or something like this, and the third throwed same exception as soon as I pressed 'invoke'...
Then I tried to declare any function with parameter of object, which I don't know, wheter it is functional, as I cannot test it through IE since "it doesn't support HTTP GET method". :(
Any ideas?:confused:
Cander
Jan 7th, 2002, 08:35 AM
Ill do some looking around to see what I can find since this is an interesting idea.
Cander
Jan 7th, 2002, 08:41 AM
ack.. doesnt look possible according to this
http://samples.gotdotnet.com/quickstart/aspplus/doc/webservicetypes.aspx
i guess the only option is to break it down into a byte array that the client would have to manually code to rebuild.
:(
Jhd.Honza
Jan 8th, 2002, 12:24 PM
This seems to be quite good argument. :(
However, I think there should be some better support for binaries (or text files as well) than splitting it into an array, what is not so good idea. Imagine, even sending <byte> and </byte> enlarges the file 7 times :eek: (in addition to spaces, bytes represented by string, and line feeds).
I don't believe realizing such simple services, as get an image, do some effects and return image, or translate documents or whatever else, will be too complicated, or?
Another poor idea - to encode the file (uuencode, mime) and to send it as long string or something.
Cander
Jan 8th, 2002, 12:34 PM
well yeah as a string would be ok to...I really meant to say byte array or as a string.... Either way there just isnt any better option as now that I think about it, binary support would go outside the bounds of what xml does and I believe MS is trying to get away from adding propietary functionailty to open standards.
Jhd.Honza
Jan 8th, 2002, 04:37 PM
Well, it seems there is not any other possibility :(, so...
I have web service returning encoded image as string
I think there is no problem, encoding can be done manually, if not already present in some system libraries
Client is an ASP.NET page
which should encode and display the image. And here I have no idea how to transform a string into bitmap...
...unless... :D ... unless I force IE to encode and display the image itself, as in MHT files. But this would limite reciever to use only IE...
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.