开发者

Cannot send Image data type from web service

I use this lines of code in web service to send data:

 byte[] bajtat = (byte[])dr["Logo"];
                            MemoryStream ms = new MemoryStream(bajtat, 0, bajtat.Length);
                            ms.Write(bajtat, 0, bajtat.Length);
                            Image img = Image.FromStream(ms, true);


                            var partite = new Partite
                            {
                                EmriPartite = dr.GetString(2),
                                /*
                                 *   SqlDataReader.GetString - gets the value of the specified column as a string
                          开发者_JAVA技巧       */
                                NrPartive = dr.GetInt32(1),
                                Akronimi = dr.GetString(4),
                                Foto = img
                            };

and it shows me error:

System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.InvalidOperationException: There was an error generating the XML document. ---> System.InvalidOperationException: The type System.Drawing.Bitmap was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically. at


There should not be any problem in sending image data as byte[] from WebService using WCF technology. You can use [DataMember] byte[] for you DataContract class. Read the image data completely to byte[] field. And send using WCF service.

At the receiving part in WP7, you can have

 
    < Image Source={Binding MyImageSource} />
Where MyImageSource is a BitmapSource Type.
    And you can set its instance .SetSource(new MemoryStream(buffer, 0, buffer.Length));
Where buffer is the byte[].
 

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜