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 ...
随机推荐
- bootstrap的总结1 - 网格系统
1.Bootstrap 网格系统 1)下表总结了 Bootstrap 网格系统如何跨多个设备工作: 2)Bootstrap 网格的基本结构 <div class="container& ...
- Opencv2.2版本以上CvvImage类的使用
Opencv 2.2以上的版本不再包含CvvImage类,可有时我们在MFC中显示图片仍然需要CvvImage类,特别进行图像的拷贝.显示等操作的时候. 早期版本的CvvImage.h添加进工程也是可 ...
- drupal7 修改文件上传大小限制
参考文章:Drupal 7 设置上传文件的限制大小 自己用 '#type' => 'managed_file'做了一个上传的功能,但是上传时总是说超过了2M的限制,接下来说一下怎么修改限制. 一 ...
- HTML 标记
- Activity的生命周期和启动模式
Activity的生命周期分析 典型情况下的生命周期.是指在用户参与的情况下,Activity所经过的生命周期的改变. 异常情况下的生命周期.是指Activity被系统回收或者由于当前设备的Confi ...
- android --拍照,从相册获取图片,兼容高版本,兼容小米手机
前几天做项目中选择图片的过程中遇到高版本和小米手机出现无法选择和崩溃的问题,现在记录下来,后面出现同类问题,也好查找 1,定义常量: private static final int TAKE_PIC ...
- hdu 1531 King
首先吐槽一下这个题目的题意描述,我看了半天才明白. 下标全部都是乱标的!!!!出题者能不能规范一点下标的写法!!!! 差分约束系统 #include<cstdio> #include< ...
- USACO 2.4 Cow Tours
Cow Tours Farmer John has a number of pastures on his farm. Cow paths connect some pastures with cer ...
- 一个突发性的误解C# 引用类型
最近再看IOCP,结果里面的一个赋值过程,造成了误解. test t1 = new test(); test t2 = new test(); test t4 = new test(); t1= t2 ...
- js--事件对象的理解2
实例1:一串跟着鼠标飞舞的div <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "h ...