理解 Soap
http://www.cnblogs.com/yhuang/archive/2012/04/04/share_storm.html
自己也写了下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MyCmn;
using System.Web;
using System.Net;
using System.IO; namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
var str = @"<?xml version=""1.0"" encoding=""utf-8""?>
<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"">
<soap:Body>
<Login xmlns=""MyServer"">
<RequestJson>{WebName:""iudi"",Password:""iudi""}</RequestJson>
</Login>
</soap:Body>
</soap:Envelope>"; HttpWebRequest request = HttpWebRequest.Create("http://udi-pc/WcfService/AndroidApp.svc") as HttpWebRequest;
request.Method = "POST";
request.Headers["SoapAction"] = "MyServer/AndroidApp/Login";
request.ContentType = "text/xml; charset=utf-8";
request.Pipelined = true;
request.AllowAutoRedirect = true;
request.KeepAlive = true;
request.Headers["UseCookieContaner"] = "True"; var rs = request.GetRequestStream(); var ary1 = System.Text.Encoding.UTF8.GetBytes(str);
rs.Write(ary1, , ary1.Length); var resp = request.GetResponse() as HttpWebResponse; using (var respStream = resp.GetResponseStream())
{
System.IO.BinaryReader reader = new BinaryReader(respStream);
byte[] ary = null;
if (resp.ContentLength <= )
{
var listAry = new List<byte>(); while (true)
{
var tempAry = reader.ReadBytes();
if (tempAry.Length == ) break;
listAry.AddRange(tempAry);
} ary = listAry.ToArray();
}
else
{
ary = reader.ReadBytes(resp.ContentLength.AsInt());
} var html = "";
if (resp.CharacterSet.HasValue())
{
html = System.Text.Encoding.GetEncoding(resp.CharacterSet).GetString(ary);
}
else
{
html = System.Text.Encoding.Default.GetString(ary);
} Console.WriteLine(html);
} }
}
}
理解 Soap的更多相关文章
- WCF 出现无法理解Soap Action问题?
在使用wcf部署到asp.net上时,遇到了,“无法理解soap Action 问题,”最简单的解决办法是更换NET framwork 高本版的框架. 不过不更换net framwork 框架,能否解 ...
- php中soap的使用实例以及生成WSDL文件,提供自动生成WSDL文件的类库——SoapDiscovery.class.php类
1. web service普及: Webservice soap wsdl区别之个人见解 Web Service实现业务诉求: Web Service是真正“办事”的那个,提供一种办事接口的统称. ...
- php学习之道:php中soap的使用实例以及生成WSDL文件,提供自己主动生成WSDL文件的类库——SoapDiscovery.class.php类
1. web service普及: Webservice soap wsdl差别之个人见解 Web Service实现业务诉求: Web Service是真正"办事"的那个,提供 ...
- Webservice soap wsdl区别之个人见解
原文:http://blog.csdn.net/pautcher_0/article/details/6798351 Web Service实现业务诉求:Web Service是真正“办事”的那个,提 ...
- SOAP协议初级指南 (一)
SOAP(Simple Object Access Protocal) 技术有助于实现大量异构程序和平台之间的互操作性,从而使存在的应用能够被广泛的用户所访问.SOAP是把成熟的基于HTTP的WEB技 ...
- 浅谈 SOAP
http://www.ibm.com/developerworks/cn/xml/x-sisoap/ 本文对 SOAP 作了一个初步介绍,给出几个简单示例:接着比较 CORBA,DCOM/COM 与 ...
- 使用JQuery的Ajax调用SOAP-XML Web Services(Call SOAP-XML Web Services With jQuery Ajax)(译+摘录)
假设有一个基于.Net的Web Service,其名称为SaveProduct POST /ProductService.asmx HTTP/1.1 Host: localhost Content-T ...
- 06_WebService与Socket的区别
[区别] 区别1. Socket是基于TCP/IP的传输层协议. WebService是基于HTTP协议传输数据的,HTTP是基于TCP的应用层协议. 区别2. WebService采用了基于HTTP ...
- WebService学习笔记系列(二)
soap(简单对象访问协议),它是在http基础之上传递xml格式数据的协议.soap协议分为两个版本,soap1.1和soap1.2. 在学习webservice时我们有一个必备工具叫做tcpmon ...
随机推荐
- oneCMDB
OneCMDB开源地址: http://www.oschina.net/p/onecmdb/, 官方网站:http://www.onecmdb.org/wiki/index.php?title=Mai ...
- HashMap的面试总结(摘抄)
HashMap的工作原理是近年来常见的Java面试题.几乎每个Java程序员都知道 HashMap,都知道哪里要用HashMap,知道HashTable和HashMap之间的区别,那么为何这道面试题如 ...
- ios block和函数的区别
block是封装了一段代码的OC对象,可以被设为Property, 在调用block的地方block都会被替换成相应的代码,相当于内联函数. 函数可以使代码更加整洁易读,使用block会使代码可读性变 ...
- Spring MVC常见的三种URL请求参数的处理
//方法1:@RequestParam //url:/test1?id=123 @RequestMapping(value = "/test1",method = RequestM ...
- flash项目优化总结
swc中的类如果没有在项目中没有被申明,在编译时就不会被编译进swf中,这样一些swc中的类和资源类如果不用了,只要不被声明就不会占用swf大小了.
- 最长子串 FZU2118
http://acm.fzu.edu.cn/problem.php?pid=2128 分析:利用strstr()函数将每个字串在原串中的首尾位置存储一下,再将首尾从小到大排一下序.(写着写着就感觉和看 ...
- win32api 获取文件版本信息
#coding:utf-8 myPath="C:\\ime" import os from win32api import GetFileVersionInfo, LOWORD, ...
- 如何使用JS脚本从HTML中分离图片标签与文本,替换文本中指定的内容并加粗(原创)
var html='ddfsdfsdfdsd dfsdfsdffds<img _src="http://localhost:8490/60E86EA7-FE7B-44BF-8270-4 ...
- instr函数
在Oracle/PLSQL中,instr函数返回要截取的字符串在源字符串中的位置. 语法如下:instr( string1, string2 [, start_position [, nth_appe ...
- highcharts 使用实例
后端使用django实现,返回的数据可以修改为从数据库获取或其他方式获取,实例里是写死的数据. urls配置: url(r'^outip/chart/$', views.charts), url(r' ...