zoukankan      html  css  js  c++  java
  • 内存流操作

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.IO;
    using System.Runtime.Serialization;
    using System.Runtime.Serialization.Formatters.Soap;
    using System.Runtime.Remoting.Messaging;
    using System.ServiceModel.Channels;
    
    using System.Xml;
    namespace SoapTest
    {
        public class ConvertToSoap
        {
            public static void GetSoap(Person person)
            {
                SoapFormatter soapFormatter = new SoapFormatter();
                using(MemoryStream stream = new MemoryStream())
                {
                    soapFormatter.Serialize(stream, person, new Header[] { new Header("Name","abc"), new Header("Password","aaaa") });
                    byte[] btys = new byte[stream.Length];
                    btys = stream.ToArray();
    
                    string rs = Encoding.UTF8.GetString(btys, 0, btys.Length);
                    stream.Flush();
                    Console.WriteLine(rs);
                    Console.ReadKey();
                    
                }
    
                using (XmlTextWriter write = new XmlTextWriter("D://soap.txt", Encoding.UTF8))
                {
                     write.Formatting = Formatting.Indented;
                     Message msg = Message.CreateMessage(MessageVersion.Soap12,
                         "http://www.cnblogs.com/",person);
                     msg.WriteMessage(write);
                }
            }
        }
    }
  • 相关阅读:
    图书管理系统时序图和活动图
    图书管理用例图
    课堂练习(团队)
    课堂练习(RASCI模型)
    课堂练习(分析设想app)
    课堂练习(NABCD model)
    课堂练习(问答题)
    测试用例
    课堂练习(测试计划)
    错误报告
  • 原文地址:https://www.cnblogs.com/huangzelin/p/4552220.html
Copyright © 2011-2022 走看看