HTTP SOAP Request
public string SoapRequest(string url, string message, string type, Encoding encoding)
{
string result = string.Empty;
Stream reqstr = null;
System.IO.Stream responseStream = null;
System.IO.StreamReader reader = null;
try
{
HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
request.Method = type.ToString();
request.ContentType = "application/soap+xml;charset=UTF-8;action=\"" + url + "\"";
request.Headers.Add("SOAPAction", url); if (type.ToString().ToLower() == "post")
{
reqstr = request.GetRequestStream();
byte[] buff = encoding.GetBytes(message);
reqstr.Write(buff, , buff.Length);
reqstr.Flush();
reqstr.Close();
reqstr.Dispose();
reqstr = null;
}
// 接收返回的页面
HttpWebResponse response = request.GetResponse() as HttpWebResponse;
responseStream = response.GetResponseStream();
reader = new System.IO.StreamReader(responseStream, encoding);
result = reader.ReadToEnd();
if (OnStateComplate != null)
OnStateComplate(result, fspc);
if (OnReplyComplate != null)
OnReplyComplate(result, fspc);
return result;
}
catch (Exception ex)
{
throw ex;
}
finally
{
if (reader != null)
{
reader.Close();
reader.Dispose();
}
if (reqstr != null)
{
reqstr.Flush();
reqstr.Close();
reqstr.Dispose();
}
if (responseStream != null)
{
responseStream.Flush();
responseStream.Close();
responseStream.Dispose();
}
} }
public static string GetStringSOAP1(Hashtable ht,string target)
{
StringBuilder body = new StringBuilder();
body.Append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
body.Append("<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">");
body.Append("<soap:Body>");
body.Append("<"+target+" xmlns=\"http://service.pubinfo.com.cn\">");
body.AppendFormat("<in0>{0}</in0>", ht["loginName"].ToString());
body.AppendFormat("<in1>{0}</in1>", ht["loginPWD"].ToString());
int index = ;
if (ht.ContainsKey("mobiles") && !string.IsNullOrEmpty(ht["mobiles"].ToString()))
{
body.AppendFormat("<in{1}>{0}</in{1}>", ht["mobiles"].ToString(),index++);
}
if (ht.ContainsKey("content") && !string.IsNullOrEmpty(ht["content"].ToString()))
{
body.AppendFormat("<in{1}>{0}</in{1}>", ht["content"].ToString(), index++);
}
if (ht.ContainsKey("sendNo") && !string.IsNullOrEmpty(ht["sendNo"].ToString()))
{
body.AppendFormat("<in{1}>{0}</in{1}>", ht["sendNo"].ToString(), index++);
}
body.Append("</"+target+"></soap:Body></soap:Envelope>");
return body.ToString();
}
HTTP SOAP Request的更多相关文章
- soap request by afnetworking2.X/3.X
for 2.X 参考 http://jiapumin.iteye.com/blog/2109378 AFHTTPRequestOperationManager *manager = [AFHTTPRe ...
- 【转载】C# HttpWebRequest 发送SOAP XML
调用webservice的几种方法: 方法一:添加web引用(简单/方便 局限客户端是.net) 方法二:Post xml(本文重点讲述) 方法三:使用微软MSXML2组件(好像在window ser ...
- 译-Web Service剖析: XML, SOAP 和WSDL 用于独立于平台的数据交换
本文是翻译内容,原文参见: Anatomy of a Web Service: XML, SOAP and WSDL for Platform-independent Data Exchange We ...
- SOAP Binding: Difference between Document and RPC Style Web Services
SOAP Binding: Difference between Document and RPC Style Web Services 20FLARES Twitter 1Facebook 9Goo ...
- 通过JavaScript调用SOAP终结点执行实体消息
关注本人微信和易信公众号: 微软动态CRM专家罗勇 ,回复148或者20150813可方便获取本文,同时可以在第一时间得到我发布的最新的博文信息,follow me! 利用OData终结点可以方便的对 ...
- webService(SOAP)性能测试脚本
本文以天气预报的webService为基础进行学习 webService地址:http://www.webxml.com.cn/WebServices/WeatherWebService.asmx ...
- 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 ...
- Loadrunner 9.5_webservice(SOAP)性能测试
WebService定义:Webservice是一种新的使用基于XML标准和协议来交换信息的WEB应用程序.是基于SOAP(简单对象访问协议)消息的应该协议,只是为WEB页面或可执行程序提供编程接口. ...
- (转)Java实现Web Service过程中处理SOAP Header的问题
网上有篇文章,大致这么说的(如下文),最后我采用的wsimport -XadditionalHeaders的方式. StrikeIron offers two authentication meth ...
随机推荐
- JavaScript忍者秘籍——闭包
概要:本篇博客主要介绍了JavaScript的闭包 1.闭包的工作原理 简单地说,闭包就是一个函数在创建时允许该自身函数访问并操作该自身函数之外的变量时所创建的作用域. 例如: var outerVa ...
- JDBC:四步完成MySQL数据库的连接
->首先,将MySQL的jar包引入 ->然后创建一个.properties的文件(例:connection.properties),在该文件中写入如下代码: jdbc.driver.cl ...
- [SOJ] DAG?
Description 输入一个有向图,判断该图是否是有向无环图(Directed Acyclic Graph). Input 输入的第一行包含两个整数n和m,n是图的顶点数,m是边数.1<=n ...
- HDOJ-1051 Wooden sticks(贪心)
Wooden Sticks Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...
- JAVA多态问题总结(课堂总结)
面向对象的三大特性:封装.继承.多态.从一定角度来看,封装和继承几乎都是为多态而准备的.这是我们最后一个概念,也是最重要的知识点.多态的定义:指允许不同类的对象对同一消息做出响应.即同一消息可以根据发 ...
- Unity 5 Game Optimization
2. Scripting Strategies 2.1 Cache Component references (缓存组件引用) 使用 Rigidbody rigidbody = GetComponen ...
- C/C++中整数与浮点数在内存中的表示方式
在C/C++中数字类型主要有整数与浮点数两种类型,在32位机器中整型占4字节,浮点数分为float,double两种类型,其中float占4字节,而double占8字节.下面来说明它们在内存中的具体表 ...
- oracle导入dmp数据库文件
要用sys账户登录数据库,创建和dmp文件一样的表空间名称 1. 创建表空间 例如: create tablespace test(表空间名称) datafile 'F:\oracle\oradata ...
- HDU 5861 Road
首先要计算出每一条路最早开始的那一天,然后最晚结束的那一天. 这些天之间这条边都必须$open$,然后就变成一个线段树区间$+val$的问题了,最后询问一个每个点的$val$是多少. 注意:数据中有$ ...
- 【转】HTML-based script和URL-based script两种脚本录制方式
在Web(HTTP/HTML)录制中,有2种重要的录制模式.用户该选择那种录制模式呢?HTML-mode录制是缺省也是推荐的录制模式.它录制当前网页中的HTML动作.在录制会话过程中不会录制所有的资源 ...