2011-09-25 3 views
0

웹 서비스에서 이미지 데이터 형식을 보낼 수 없습니다 :내가 데이터를 전송하는 웹 서비스 코드의 라인을 사용

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 
           */ 
           NrPartive = dr.GetInt32(1), 
           Akronimi = dr.GetString(4), 
           Foto = img 
          }; 

을 그리고 그것은 나에게 오류 보여줍니다

System.Web.Services.Protocols.SoapException을 : 서버가 요청을 처리 할 수 ​​없습니다. ---> System.InvalidOperationException : XML 문서를 생성하는 중 오류가 발생했습니다. System.InvalidOperationException ---> System.Drawing.Bitmap 형식이 필요하지 않습니다. 정적으로 알 수없는 형식을 지정하려면 XmlInclude 또는 SoapInclude 특성을 사용하십시오. at

답변

0

WCF 기술을 사용하여 WebService에서 이미지 데이터를 byte []로 전송할 때 문제가 없어야합니다. DataContract 클래스에 대해 [DataMember] byte []를 사용할 수 있습니다. 이미지 데이터를 byte [] 필드로 완전히 읽습니다. WCF 서비스를 사용하여 보내십시오.

WP7의 수신 부분에서

, 당신은 내가이 코드를 만들 내가 답을 만드는 방법을 모르는


    < 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

(123) 개발자를 가질 수 있습니다 바이트 [] 버퍼 = 바이트로 값 []; BitmapSource MyImageSource; // 새로운 BitmapSource()를 만들 수 없습니다. MyImageSource.SetSource (new MemoryStream (buffer, 0, buffer.Length); – Edon

관련 문제