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的更多相关文章

  1. soap request by afnetworking2.X/3.X

    for 2.X 参考 http://jiapumin.iteye.com/blog/2109378 AFHTTPRequestOperationManager *manager = [AFHTTPRe ...

  2. 【转载】C# HttpWebRequest 发送SOAP XML

    调用webservice的几种方法: 方法一:添加web引用(简单/方便 局限客户端是.net) 方法二:Post xml(本文重点讲述) 方法三:使用微软MSXML2组件(好像在window ser ...

  3. 译-Web Service剖析: XML, SOAP 和WSDL 用于独立于平台的数据交换

    本文是翻译内容,原文参见: Anatomy of a Web Service: XML, SOAP and WSDL for Platform-independent Data Exchange We ...

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

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

  5. 通过JavaScript调用SOAP终结点执行实体消息

    关注本人微信和易信公众号: 微软动态CRM专家罗勇 ,回复148或者20150813可方便获取本文,同时可以在第一时间得到我发布的最新的博文信息,follow me! 利用OData终结点可以方便的对 ...

  6. webService(SOAP)性能测试脚本

    本文以天气预报的webService为基础进行学习   webService地址:http://www.webxml.com.cn/WebServices/WeatherWebService.asmx ...

  7. 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   ...

  8. Loadrunner 9.5_webservice(SOAP)性能测试

    WebService定义:Webservice是一种新的使用基于XML标准和协议来交换信息的WEB应用程序.是基于SOAP(简单对象访问协议)消息的应该协议,只是为WEB页面或可执行程序提供编程接口. ...

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

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

随机推荐

  1. 在GNU/Linux下使用命令行自动挂载与卸载USB磁盘

    在命令行环境下如果每次都是靠手动敲入mount与umount命令来挂载与卸载USB磁盘是件很麻烦的事情.尤其是mount命令的参数非常多.比如,磁盘的分区类型(vfat.ntfs等),挂载的目录节点, ...

  2. [其他]win7下chrome浏览器插件导出与导入

    下载了某些插件,重装电脑怎么不备份,重装之后怎么再次使用,一文搞定! 导出crx格式备份文件 1.选择 自定义格式及控制 > 更多工具 > 扩展程序: 2.勾选"开发者模式&qu ...

  3. 3天CSS总结

    css的重点和难点是盒子模型中的margin.padding.border.属性,还有浮动也是重点.

  4. python的web开发环境Django配置

    我的系统的windows10: 第一步,安装python3.5 第二步,配置django,如图所示,在python的安装目录下的Scripts里面执行:pip install Django,我这儿提示 ...

  5. 小白学C++的小问题

    昨天开始学习C++,使用的visual studio 2012. 1命名要有意义,避免用a,b,c,尽量使用num,result等让人看见就能明白相关含义的名字 2要有一定的注释,注释和有意义的命名可 ...

  6. python 小程序(1)

    这是在一个文件夹下将符合条件的文件中,第一列是相同的,对每个文件中第二列的数求和,输出为一个txt文件,文件内容格式为:第一列的每个数对应[这个所有符合条件的文件中第一列这个数对应的第二个数的]求和 ...

  7. 比较C++中的4种类型转换方式(转自http://blog.csdn.net/hrbeuwhw/article/details/7884797)

    C++的四种cast操作符的区别 Q:什么是C风格转换?什么是static_cast, dynamic_cast 以及 reinterpret_cast?区别是什么?为什么要注意? A:转换的含义是通 ...

  8. (转载)#include机制,#ifndef...#define...#endif防止重复引用,声明,定义等概念

    一.来自百度知道的问题:全局变量可以声明定义在头文件中? 答案: 注意头文件中不可以放变量的定义!!!一般情况下头文件中只放变量的声明,因为头文件要被其他文件包含(即#include).如果把定义放到 ...

  9. POJ 2305 Basic remains(进制转换)

    题目链接:http://poj.org/problem?id=2305 ime Limit: 1000MS   Memory Limit: 65536K Total Submissions: 5326 ...

  10. C#字符串转INT

    Convent.ToInt32(string ) 可以转化字符串   其他 * .tostring();   (int ) char //强制类型转换 不能转化字符串