日期:2014-05-17  浏览次数:20479 次

怎么用WebService传输XML文件



RT 

还有
C# code
XmlWriter writer = null;
            try
            {
                //创建一个XMLSerializer对象
                XmlSerializer serializer = new XmlSerializer(fbs.GetType());
                //将XMLWriter对象赋值为XMLTextWriter对象
                writer = new XmlTextWriter([color=#FF0000]Response[/color].OutputStream, System.Text.Encoding.UTF8);
                //调用序列化方法

                serializer.Serialize(writer, fbs);
            }
            finally
            {
                if (writer != null)
                {
                    writer.Close();
                }
            }



Response 在webservice中不能用 为什么

------解决方案--------------------
参考:

XmlSerializer xmlSerializer = new XmlSerializer(typeof(Person));

StringWriter stringWriter = new StringWriter();

xmlSerializer.Serialize(stringWriter, p1);

string serializedXML = stringWriter.ToString();

返回string就可以了