好像只能返回简单对像 DataSet ,数组等
   不过你可以自已写消息人编码5和解码了

解决方案 »

  1.   

    DateSet和图片都是可以返回的,试一下就知道了
    [WebMethod]
    public DataSet getDataSet()
    {
      DataSet tmpDS=new DataSet();
      return tmpDS;
    }
      

  2.   

    可以返回但具体要看你用什么来调用它用.Net的话就可以成功解析DataSet。。而其它需要来解析生成的Xml。。
      

  3.   

    可不可以这样理解:对于.NET的服务器来说,这些都是可以返回的;但是客户端必须也是.NET才能正确读取,否则就需要自己解析?那么这个复杂对象序列化的过程,是由.NET自己来做,还是要手动序列化?记得DataSet里封装了一个序列化方法多谢多谢
      

  4.   

    如果是自定义的对象,首先两边都要有这个对象的引用,并且该对象必须继承自MarshalByValueComponent。大致是这个意思,我并没做过。
      

  5.   

    不是客户端。。而是调用者看看WebService提供的接口数据格式。。调用者是否支持
      

  6.   

    多谢多谢,对,我所说的“客户端”是指调用者DataSet确实是派生自MarshalByValueComponent,可图片就不是了,如果我要通过Webservice取得图片怎么办呢?没有人在.NET下通过WebService传过图片吗?
    请大家多多帮忙呀,谢谢拉
      

  7.   

    xml在解析图片可能会有问题,但dataset肯定支持
      

  8.   

    真的这样呀,那么大家是怎么用WebService传送图片对象呢,请大家说说好吗?比如数据库里有幅相关设备的照片.............
      

  9.   

    希望对你有用http://www.digitalearth.net.cn/GISRelatedITIssues/ASP.Net/Base64.htm
      

  10.   

    呵呵。。去晚了吧
    我只好从IE临时文件中给你找了。本文说明如何创建和使用二进制数据传送的Web服务,这是相当容易的一件事。 =================================================================在示例中,将从本地磁盘取出图象数据,然后使用SOAP信息将图象传送到调用者手上。
    现在开始讨论有关的Web服务,并特别注重数据编码的有关操作。0.  [WebMethod(Description="Get an Image using Base64 Encoding")] 
    1.  public byte[] GetImage() { 
    2.   return getBinaryFile("C:\\Inetpub\\wwwroot\\webservices\\public\\images\\logo.gif"); 
    3.   } 
    4.   注意函数返回byte[] (字节数组)。.NET将自动将返回的数据编码成为base64格式。下面的"getBinaryFile()"函数用文件流从硬盘读取文件,然后将图象文件数据转换为byte[]:0.  public byte[] getBinaryFile(string filename) { 
    1.   if(File.Exists(filename)) { 
    2.    try { 
    3.     FileStream s=File.OpenRead(filename); 
    4.     return ConvertStreamToByteBuffer(s); 
    5.     }
       catch(Exception e) { 
    6.     return new byte[0]; 
    7.     } 
    8.    }
      else { 
    9.    return new byte[0]; 
    10.   } 
    11.  } 
    12.   
    13.  public byte[] ConvertStreamToByteBuffer(System.IO.Stream theStream) { 
    14.   int b1; 
    15.   System.IO.MemoryStream tempStream = new System.IO.MemoryStream(); 
    16.   while((b1=theStream.ReadByte())!=-1) { 
    17.    tempStream.WriteByte(((byte)b1)); 
    18.    } 
    19.   return tempStream.ToArray(); 
    20.   } 
    现在可以在.NET上用C#编写客户端程序,过程如下:
    1. 创建C#应用窗体
    2. 增加一个Picture Box控件,命名为pct1
    3. 增加一个Web引用(Reference)到:http://rob.santra.com/webservices/public/images/index.asmx?wsdl
    4. 在程序的事件驱动(Form1_Load, 或其它事件)中写入以下代码:
     0.  com.santra.rob.Images images = new com.santra.rob.Images(); 
     1.  byte[] image = images.GetImage(); 
     2.  System.IO.MemoryStream memStream = new System.IO.MemoryStream(image); 
     3.  Bitmap bm = new Bitmap(memStream); 
     4.  pct1.Image = bm; 
     5.   
     6.   如果是在自己的服务器上创建这种服务,就要改变Web Reference(引用)地址,同时com.santra.rob.Images()对象也要与增加Web Reference(引用)时创建的对象相一致。在上面的代码中,客户向服务器申请含有图象数据的字节数组,并将该数组转换到内存流(MemoryStream),然后加载到Bitmap对象,最后用pct1图象控件显示得到的图象。整个过程就是这么简单!
      

  11.   

    以下是全部代码:0.  <%@ Webservice Language="C#" class="Images" %> 
    1.   
    2.  using System; 
    3.  using System.Web.Services; 
    4.  using System.IO; 
    5.   
    6.  [WebService(Namespace="http://rob.santra.com/webservices/public/images/", Description="Demonstration of using Base64 encoding, in a Web Service using the .NET Framework.")] 7.    public class Images: System.Web.Services.WebService { 
    8.     [WebMethod(Description="Get an Image using Base64 Encoding")] 
    9.     public byte[] GetImage() { 
    10.    return getBinaryFile("C:\\Inetpub\\wwwroot\\webservices\\public\\images\\logo.gif"); 
    11.   } 
    12.   public byte[] getBinaryFile(string filename) { 
    13.    if(File.Exists(filename)) { 
    14.     try { 
    15.      FileStream s=File.OpenRead(filename); 
    16.      return ConvertStreamToByteBuffer(s); 
    17.      }
         catch(Exception e) { 
    18.       return new byte[0]; 
    19.      } 
    20.     }
        else { 
    21.     return new byte[0]; 
    22.     } 
    23.    } 
    24.   
    25.   public byte[] ConvertStreamToByteBuffer(System.IO.Stream theStream) { 
    26.    int b1; 
    27.    System.IO.MemoryStream tempStream = new System.IO.MemoryStream(); 
    28.    while((b1=theStream.ReadByte())!=-1) { 
    29.     tempStream.WriteByte(((byte)b1)); 
    30.     } 
    31.    return tempStream.ToArray(); 
    32.    } 
    33.   }