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 ...
随机推荐
- Thrift学习记录
Thrift学习记录 Thrift是一个软件框架,用来进行可扩展且跨语言的服务的开发.它结合了功能强大的软件堆栈和代码生成引擎,以构建在C++,Java,Python,PHP,Ruby,Erlang, ...
- C#在客户端验证数字证书(Certificate)
ServicePointManager.ServerCertificateValidationCallback = CertificateValidationCallback;//Init时执行,用于 ...
- JQ怎么跳出 each循环
return false;——跳出所有循环:相当于 javascript 中的 break 效果. return true;——跳出当前循环,进入下一个循环:相当于 javascript 中的 con ...
- php笔记(八)PHP类与对象之抽象类
<?php //通过abstract关键字定义一个抽象类 abstract class ACanEat{ //通过abstract关键字定一个不用具体实现的抽象方法eat() abstract ...
- ng-Directive
伪代码: var myModule = angular.module(...); myModule.directive('namespaceDirectiveName', function facto ...
- jmeter下载及安装配置
本文是在win7环境下安装使用jmeter,jmeter可以运行在多平台上Windows和Linux. 前提:使用jmeter工具之前需要安装java.并配置好java的环境变量.(备注:java下载 ...
- iOS 打包上传AppStore相关(2)-Xcode相应配置
上一篇描述了如何在AppleDeveloper创建Certificates.App IDs和Provisioning Profiles的过程.本篇将详细描述在Xcode部分我们需要做的配置. 1.配置 ...
- JPA 系列教程21-JPA2.0-@MapKeyColumn
@MapKeyColumn 用@JoinColumn注解和@MapKeyColumn处理一对多关系 ddl语句 CREATE TABLE `t_employee` ( `id` bigint(20) ...
- github 上传文件
1.删除项目 2. 包管理器初始化 npm init name 必填项 后面可一直回车 最后选择yes 3.建立本地仓储 在git bash 中输入命令 git init 4. 添加 ...
- Linux之top
简介 top命令是Linux下常用的性能分析工具,能够实时显示系统中各个进程的资源占用状况,类似于Windows的任务管理器. top显示系统当前的进程和其他状况,是一个动态显示过程,即可以通过用户按 ...