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) ...
随机推荐
- ROS节点的初始化及退出详解(ros::init、SIGINT、ros::ok、ros::NodeHandle
https://haoqchen.site/2018/04/28/ROS-node-init/ #include "ros/ros.h" #include <signal.h ...
- Ionic 不随系统字体而变化
1.添加插件phonegap-plugin-mobile-accessibility cordova plugin add https://github.com/phonegap/phonegap-m ...
- CSS3属性transform详解【转载】
CSS3属性transform详解之(旋转:rotate,缩放:scale,倾斜:skew,移动:translate) 在CSS3中,可以利用transform功能来实现文字或图像的旋转.缩放.倾 ...
- MyBatis与JPA的区别是什么
MyBatis分为全注解版和xml版:全注解版适合于小项目,直接在方法上加注解,在注解中写sql 仓储Repository 模式是领域驱动设计中另一个经典的模式.在早期,我们常常将数据访问层命名为:D ...
- Python学习之for循环--输出1-100中的偶数和登录身份认证
输出1-100中的偶数 效果图: 实现代码: for i in range(2,101,2): print(i,end = '\t') if(i == 34): print('\n') if (i = ...
- java 实现文件内容的加密和解密
package com.umapp.test; import java.io.FileInputStream; import java.io.FileOutputStream; import java ...
- Luogu P2864 [USACO06JAN]树林The Grove(bfs)
P2864 [USACO06JAN]树林The Grove(bfs) 题面 题目描述 The pasture contains a small, contiguous grove of trees t ...
- js构造函数+原型
注:普通对象与函数对象 var o1 = {}; var o2 =new Object(); var o3 = new f1(); function f1(){}; var f2 = function ...
- 前端路由的实现(三) —— History的pushState和replaceState用法
HTML5中history提供的pushState, replaceState这两个API.它们提供了操作浏览器历史栈的方法. pushState能够在不加载页面的情况下改变浏览器的URL.这个方法接 ...
- 没有ORM库的时候,通过PDO连接MySQL的方法
$pdo = new PDO("mysql:host=localhost;dbname=eq","root","root"); $pdo-& ...