/// <summary>
   /// Converts a SOAP string to an object
   /// </summary>
   /// <typeparam name="T">Object type</typeparam>
   /// <param name="SOAP">SOAP string</param>
   /// <returns>The object of the specified type</returns>
   public static T SOAPToObject<T>(string SOAP)
   {
       if (string.IsNullOrEmpty(SOAP))
      {
          throw new ArgumentException("SOAP can not be null/empty");
      }

using (MemoryStream Stream = new MemoryStream(UTF8Encoding.UTF8.GetBytes(SOAP)))
      {
          SoapFormatter Formatter = new SoapFormatter();

return (T)Formatter.Deserialize(Stream);
      }
  }

/// <summary>
  /// Converts an object to a SOAP string
  /// </summary>
  /// <param name="Object">Object to serialize</param>
  /// <returns>The serialized string</returns>
  public static string ObjectToSOAP(object Object)
  {
      if (Object == null)
      {
          throw new ArgumentException("Object can not be null");
      }

using (MemoryStream Stream = new MemoryStream())
      {
          SoapFormatter Serializer = new SoapFormatter();
          Serializer.Serialize(Stream, Object);
          Stream.Flush();

return UTF8Encoding.UTF8.GetString(Stream.GetBuffer(), 0, (int)Stream.Position);
      }
  }

Deserializing/Serializing SOAP Messages in C#的更多相关文章

  1. Web service standards: SOAP, REST, OData, and more

    Web service standards: SOAP, REST, OData, and more So far, we've covered the components of a web ser ...

  2. REST vs SOAP

    REST vs SOAP These information searched from internet most from stackoverflow. Simple explanation ab ...

  3. SOAP Binding: Difference between Document and RPC Style Web Services

    SOAP Binding: Difference between Document and RPC Style Web Services 20FLARES Twitter 1Facebook 9Goo ...

  4. C#,SOAP1.1与1.2的发布与禁用(SOAP 1.2 in .NET Framework 2.0)

    来源:https://www.codeproject.com/Articles/11878/SOAP-in-NET-Framework SOAP 1.2 in .NET Framework 2.0   ...

  5. (转)Java实现Web Service过程中处理SOAP Header的问题

    网上有篇文章,大致这么说的(如下文),最后我采用的wsimport  -XadditionalHeaders的方式. StrikeIron offers two authentication meth ...

  6. .net Framework Class Library(FCL)

    from:http://msdn.microsoft.com/en-us/library/ms229335.aspx 我们平时在VS.net里引用的那些类库就是从这里来的 The .NET Frame ...

  7. Java性能提示(全)

    http://www.onjava.com/pub/a/onjava/2001/05/30/optimization.htmlComparing the performance of LinkedLi ...

  8. JAVA6开发WebService (一)

    转载自http://wuhongyu.iteye.com/blog/807470 WebService是SOA的一种较好的实现方式,它将应用程序的不同功能单元通过中立的契约(独立于硬件平台.操作系统和 ...

  9. 【学】SoapExtension 学习

    http://msdn.microsoft.com/zh-cn/library/System.Web.Services.Protocols.SoapExtension_methods(v=vs.80) ...

随机推荐

  1. string主要操作函数

    参考博客:http://blog.csdn.net/zhenyusoso/article/details/7286456 std::string illegal(" \t\f\v\n\r\\ ...

  2. select 下拉框多选

    需要引入插件:fselect.js (此插件依赖jQ) 和 fselect.css  下载 点击查看在线演示地址 //html<select class="demo" mul ...

  3. 19-10-23-K-Aft

    没改完题就过来沽博客是不是有点不好…… ZJ一下: 好好好题. T1数组大小…… $$10^7 \rightarrow 60$$ 事实上…… $$7 \times 10^7 \rightarrow 0 ...

  4. 机器学习中的隐马尔科夫模型(HMM)详解

    机器学习中的隐马尔科夫模型(HMM)详解 在之前介绍贝叶斯网络的博文中,我们已经讨论过概率图模型(PGM)的概念了.Russell等在文献[1]中指出:"在统计学中,图模型这个术语指包含贝叶 ...

  5. jeecms项目相关配置文件

    1.application-context.xml 这个是Spring的标准配置文件,这里面配置jdbc.properties文件并初始化相应数据库连接参数到bean实例:定义数据库表映射文件*.hb ...

  6. JAVA_环境配置

    1:系统环境 windows10 64位 jdk版本:jdk-8u131-windows-x64.exe,下载地址:http://www.oracle.com/technetwork/java/jav ...

  7. 009-python一些问题整理

    1. Python中的 // 与 / 的区别 " / "  表示浮点数除法,返回浮点结果 >>> 90/30 3.0 " // " 表示整数除 ...

  8. Eureka配置问题

    在使用Spring Cloud做微服务开发中,经常会使用Eureka Server作为注册中心,如果配置不当可能会导致一些不可预期的异常信息.以下是我最近遇到的因为忽略了配置eureka.client ...

  9. linux下定位文件

    参考:http://www.cnblogs.com/ccode/p/4033088.html: 在linux命令行模式下,经常会遇到定位文件的问题,这时候采用locate和find都是可以的,下面简述 ...

  10. leyou_01_环境搭建

    1.乐优商城项目搭建 前端技术: 基础的HTML.CSS.JavaScript(基于ES6标准) JQuery Vue.js 2.0以及基于Vue的框架:Vuetify 前端构建工具:WebPack ...