Deserializing/Serializing SOAP Messages in C#
/// <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#的更多相关文章
- 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 ...
- REST vs SOAP
REST vs SOAP These information searched from internet most from stackoverflow. Simple explanation ab ...
- SOAP Binding: Difference between Document and RPC Style Web Services
SOAP Binding: Difference between Document and RPC Style Web Services 20FLARES Twitter 1Facebook 9Goo ...
- 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 ...
- (转)Java实现Web Service过程中处理SOAP Header的问题
网上有篇文章,大致这么说的(如下文),最后我采用的wsimport -XadditionalHeaders的方式. StrikeIron offers two authentication meth ...
- .net Framework Class Library(FCL)
from:http://msdn.microsoft.com/en-us/library/ms229335.aspx 我们平时在VS.net里引用的那些类库就是从这里来的 The .NET Frame ...
- Java性能提示(全)
http://www.onjava.com/pub/a/onjava/2001/05/30/optimization.htmlComparing the performance of LinkedLi ...
- JAVA6开发WebService (一)
转载自http://wuhongyu.iteye.com/blog/807470 WebService是SOA的一种较好的实现方式,它将应用程序的不同功能单元通过中立的契约(独立于硬件平台.操作系统和 ...
- 【学】SoapExtension 学习
http://msdn.microsoft.com/zh-cn/library/System.Web.Services.Protocols.SoapExtension_methods(v=vs.80) ...
随机推荐
- HZOI2019熟练剖分(tree)
题目大意:https://www.cnblogs.com/Juve/articles/11186805.html 题解: 先给出官方题解: 其实这题跟期望没什么关系,因为E=$\sum_\limits ...
- React State&生命周期
State&生命周期 State&生命周期 到目前为止我们只学习了一种方法来更新UI. 我们调用ReactDOM.render()来改变输出: function tick(){ con ...
- linux学习(三)-----linux用户管理、实用指令
用户管理 基本介绍 说明: 1.Linux 系统是一个多用户多任务的操作系统,任何一个要使用系统资源的用户,都必须首先向 系统管理员申请一个账号,然后以这个账号的身份进入系统. 2.Linux 的用户 ...
- <form>(表单)标签和常用的类型
1.定义和用法 <form> 标签用于为用户输入创建 HTML 表单. 表单能够包含 input 元素,比如文本字段.复选框.单选框.提交按钮等等. 表单还可以包含 menus.texta ...
- CentOS 6.5 usb安装
我只说一下将CentOS安装作为服务器的情况,但是适用于普遍的CentOS安装过程,首先下载CentOS的安装镜像文件,有这么几种:CentOS-6.5-x86_64-LiveCD.CentOS-6. ...
- python 当文件目录不存在时,如何自动创建
import os if not os.path.exists('foldername'): os.mkdir('foldername')
- Latex报错: Could not start the command: xelatex.exe -synctex=1 -interaction=nonstopmode?
Latex报错: Could not start the command: xelatex.exe -synctex=1 -interaction=nonstopmode 网上还有很多说出Could ...
- Phone List HDU1671 字典树Trie
模板题...不过会爆内存,要小心 #include <iostream> #include <cstdio> #include <string.h> #pragma ...
- SpringMVC注解开发方式
环境准备 springmvc版本:spring3.2 需要spring3.2所有jar(一定包括spring-webmvc-3.2.0.RELEASE.jar 工程结构 配置前端控制器(web.xml ...
- 解决C++ builder 4.0编译后的程序在某些计算机上运行出现"EAccessViolation" 的错误
1. bordbk41.dll is missing or not registered. regsvr32 "C:\Program Files (x86)\Common Files\Bor ...