使用HttpWebRequest调用wcf一段代码
public class HttpClass
{
internal static HttpWebRequest _httpWebRequest;
public static void Request()
{
_httpWebRequest = null;
_httpWebRequest = (HttpWebRequest)WebRequest.Create("http://wcf.open.cnblogs.com/blog/sitehome/paged/1/2");
_httpWebRequest.Method = "GET";
_httpWebRequest.BeginGetResponse((result) => ResponseCallback(result), _httpWebRequest);
}
static object _obj = new object();
internal static void ResponseCallback(IAsyncResult result)
{
HttpWebRequest request = (HttpWebRequest)result.AsyncState;
HttpWebResponse httpWebResponse;
try
{
httpWebResponse = (HttpWebResponse)request.EndGetResponse(result);
}
catch (WebException we)
{ return;
}
if (httpWebResponse != null)
{
lock (_obj)
{
using (var stream = httpWebResponse.GetResponseStream())
{
try
{
XmlSerializer ser = null;
object obj = null;
ser = new XmlSerializer(typeof(NewsFeed)); obj = ser.Deserialize(stream);
}
catch (Exception se)
{ return;
}
}
}
}
}
}
使用HttpWebRequest调用wcf一段代码的更多相关文章
- ASP.NET中使用HttpWebRequest调用WCF
最近项目需要和第三网站进行数据交换,第三方网站基本都是RESTfull形式的API,但是也有的是Web Service,或者.NET里面的WCF.微软鼓励大家使用WCF替代Web Service. W ...
- 三种调用WCF服务的代码
wsHttpBinding,Massage UserName认证 static void Main(string[] args) { //使用服务引用方式生成的Client调用服务,使用自动生成的配置 ...
- WCF基础教程之开篇:创建、测试和调用WCF
一转眼,又半个月没有更新博客了.说实话,最近确实是有点忙.不过即使再忙忙,也要抽空来学习一些东西.最近用WCF比较多,就来跟大家分享一下关于WCF的知识吧!为了让大家都能看懂,照顾一些没有学过WCF的 ...
- 实现jquery.ajax及原生的XMLHttpRequest调用WCF服务的方法
废话不多说,直接讲解实现步骤 一.首先我们需定义支持WEB HTTP方法调用的WCF服务契约及实现服务契约类(重点关注各attribute),代码如下: //IAddService.cs namesp ...
- SharePoint 2013 调用WCF服务简单示例
内容比较简单,主要记录自己使用SharePoint 2013WCF服务遇到的小问题和小经验,分享给大家,希望能够给需要的人有所帮助.好吧,进入正题! 第一部分 SharePoint 2013调用自带W ...
- WPF异步调用WCF服务
wpf调用wcf时,第一次访问总耗时到达几秒,影响界面的用户体验,因此在wpf加载界面和加载数据时采用异步加载,即异步访问wcf服务, 由于是否采用异步加载和服务端无关,仅仅由客户端自己根据需要来选择 ...
- 多线程编程学习笔记——异步调用WCF服务
接上文 多线程编程学习笔记——使用异步IO 接上文 多线程编程学习笔记——编写一个异步的HTTP服务器和客户端 接上文 多线程编程学习笔记——异步操作数据库 本示例描述了如何创建一个WCF服务,并宿主 ...
- 抛弃WebService,在.NET4中用 jQuery 调用 WCF
在我们之前的开发中,对于ajax程序,都是通过jQuery调用标记为[System.Web.Script.Services.ScriptService]的WebService,然后在WebServic ...
- WCF入门教程(四)通过Host代码方式来承载服务 一个WCF使用TCP协议进行通协的例子 jquery ajax调用WCF,采用System.ServiceModel.WebHttpBinding System.ServiceModel.WSHttpBinding协议 学习WCF笔记之二 无废话WCF入门教程一[什么是WCF]
WCF入门教程(四)通过Host代码方式来承载服务 Posted on 2014-05-15 13:03 停留的风 阅读(7681) 评论(0) 编辑 收藏 WCF入门教程(四)通过Host代码方式来 ...
随机推荐
- Linux服务器修改时区时间
时间的一致性很关键,对于日志的分析和程序的对接都至关重要! 01.tzselect 修改时区 可以使用命令 tzselect,修改时区.操作示例: $ tzselect Please identify ...
- CentOS安装配置Samba
介绍 Samba可以让我们在windows中访问linux系统中的文件,如果用来调试linux虚拟机中的代码会非常的方便 1.安装 yum -y update yum install samba sa ...
- Ubuntu12.04设置屏幕分辨率
Ubuntu屏幕分辨率设置 Table of Contents 1 概述 2 设置前 3 设置 4 参考 1 概述 我的Ubuntu12.04不知道被我怎么折腾了一番,屏幕的分辨率错乱了,没有办法找到 ...
- '<>' operator is not allowed for source level below 1.7
报错:'<>' operator is not allowed for source level below 1.7 这是eclipse的编译环境与项目的要求不对应造成的,这个错误一般是导 ...
- 【LeetCode】25. Reverse Nodes in k-Group (2 solutions)
Reverse Nodes in k-Group Given a linked list, reverse the nodes of a linked list k at a time and ret ...
- 【LeetCode】142. Linked List Cycle II (2 solutions)
Linked List Cycle II Given a linked list, return the node where the cycle begins. If there is no cyc ...
- Android 小技巧-- TextView与EditText 同步显示
方法一.利用View.OnKeyListener"同步"显示 EditText myEdit = (EditText)findViewById(R.id.myEdit); Tex ...
- Zookeeper监控工具
Zookeeper的常用开源监控工具可以参考:http://zqhxuyuan.github.io/2016/12/31/BigData-Monitor-Tool
- matplotlib热图
1.基础知识点回顾 1.plot(x, y, marker='D')表示绘制折线图,marker设置样式菱形. 2.scatter(x, y, marker='s', color='r')绘制散点图, ...
- DBA_实践指南系列5_Oracle Erp R12日常运维和管理(案例)
2013-12-05 Created By BaoXinjian