JQuery, Silverlight 公用WCF
WCF web.config配置:
<?xml version="1.0"?>
<configuration> <system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="" closeTimeout="00:30:00" openTimeout="00:30:00"
receiveTimeout="00:30:00" sendTimeout="00:30:00" maxBufferSize="2147483647"
maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<!--below config is for https-->
<!--<security mode="Transport">
<transport clientCredentialType="None" />
</security>-->
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="WcfHost.Service2">
<endpoint address="Ajax" behaviorConfiguration="AjaxBehavior"
binding="webHttpBinding" contract="WcfHost.Service2" />
<endpoint address="Siverlight"
binding="basicHttpBinding" contract="WcfHost.Service2" />
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="AjaxBehavior">
<enableWebScript />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer> </configuration>
在JQuery使用:
<script type="text/javascript">
var Type;
var Url;
var Data;
var ContentType;
var DataType;
var ProcessData; function WCFJSON() {
Type = "POST";
Url = "/WcfHost/Service2.svc/Ajax/GetTest";
ContentType = "application/json; charset=utf-8";
DataType = "json";
ProcessData = true;
CallService();
} function CallService() {
$.ajax({
type: Type, //GET or POST or PUT or DELETE verb
url: Url,
data: Data,
contentType: ContentType,
dataType: DataType,
processdata: ProcessData,
success: function (msg) {
ServiceSucceeded(msg);
},
error: ServiceFailed
});
} function ServiceFailed(xhr) {
alert('Service call failed: ' + xhr.status + '' + xhr.statusText);
Type = null;
varUrl = null;
Data = null;
ContentType = null;
DataType = null;
ProcessData = null;
} function ServiceSucceeded(result) {
if (DataType == "json") {
alert(result.d);
}
} $(document).ready(
function () {
WCFJSON();
}
);
</script>
WCF文件
namespace WcfHost
{
[ServiceContract(Namespace = "")]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class Service2
{
[OperationContract]
public void DoWork()
{
// Add your operation implementation here
return;
}
// Add more operations here and mark them with [OperationContract]
[OperationContract]
public string GetTest()
{
return "Test";
}
}
}
JQuery, Silverlight 公用WCF的更多相关文章
- silverlight与wcf双向通讯 例子
本文将建立一个silverlight与wcf双向通讯的简单实例,以下是详细步骤: 新建Silverlight应用程序,名称WCFtest.解决方案中添加WCF服务应用程序,名称WcfServiceTe ...
- SilverLight搭建WCF聊天室详细过程[转]
http://www.silverlightchina.net/html/zhuantixilie/getstart/2011/0424/7148.html 默认节点 SilverLight搭建WCF ...
- 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代码方式来 ...
- jquery ajax调用WCF,采用System.ServiceModel.WebHttpBinding
Jquery ajax调用WCF服务 例子效果如下:原界面 点击按钮GetList get后,通过指定的Url获取数据添加到table 新建一个控制台项目,添加IContract.cs,DBServi ...
- 系列文章--Silverlight与WCF通信
Silverlight与WCF通信(一) :Silverlight通过httpBinding访问IIS宿主WCF 摘要: 首语本人在学习Silverlight 和 WCF的时候,各种问题层出不穷,在园 ...
- Silverlight调用一般性处理程序模拟Silverlight调用WCF效果(2)
[置顶] Silverlight调用一般性处理程序模拟Silverlight调用WCF效果(2) 分类: 技术2012-03-31 12:51 548人阅读 评论(0) 收藏 举报 silverlig ...
- Silverlight调用WCF(1)
[置顶] Silverlight调用WCF(1) 分类: 技术2012-03-31 12:29 940人阅读 评论(0) 收藏 举报 wcfsilverlightexceptionusersecuri ...
- XML配置silverlight ,wcf 解析xml
XML 代码: <?xml version="1.0" encoding="utf-8" ?><ChartSet xmlns:xsi=&qu ...
- 使用Task简化Silverlight调用Wcf
原文http://www.cnblogs.com/lemontea/archive/2012/12/09/2810549.html 从.Net4.0开始,.Net提供了一个Task类来封装一个异步操作 ...
随机推荐
- 51NOD 1081 子段求和
1081 子段求和 给出一个长度为N的数组,进行Q次查询,查询从第i个元素开始长度为l的子段所有元素之和. 例如,1 3 7 9 -1,查询第2个元素开始长度为3的子段和,1 {3 7 9} ...
- Faster-RCNN-TensorFlow-Python3.5 在Ubuntu16.04下的配置方法
目录 Faster-RCNN-TensorFlow-Python3.5 在Ubuntu16.04下的配置方法 安装过程 1. 深度学习环境Tensorflow的安装 2. 安装python包 3. ...
- codevs 1191 数轴染色 区间更新加延迟标记
题目描述 Description 在一条数轴上有N个点,分别是1-N.一开始所有的点都被染成黑色.接着我们进行M次操作,第i次操作将[Li,Ri]这些点染成白色.请输出每个操作执行后剩余黑色点的个数. ...
- preg_match
$baseUrl = request()->baseUrl(); if (!preg_match('/admin.php/',$baseUrl)) { $this->redirect('/ ...
- Image():强制让图片缓存起来
Image 对象 Image 对象代表嵌入的图像. <img> 标签每出现一次,一个 Image 对象就会被创建. 创建一个Image对象:var a=new Image(); 定义 ...
- CSS sprites(css 精灵):将小图标整合到一张图片上
一.什么是css sprites css sprites直译过来就是CSS精灵.通常被解释为“CSS图像拼合”或“CSS贴图定位”.其实就是通过将多个图片融合到一张图里面,然后通过CSS backgr ...
- SpringBoot读取war包jar包Resource资源文件解决办法
SpringBoot读取war包jar包Resource资源文件解决办法 场景描述 在开发过程中我们经常会碰到要在代码中获取资源文件的情况,而我在最近在SpringBoot项目中时碰到一个问题,就是在 ...
- C# 中的集合(Array/ArrayList/List<T>/HashTable/Dictionary)
int [] numbers = new int[5]; // 长度为5,元素类型为 int. string[,] names = new string[5,4]; // 5*4 的二维数组 byte ...
- LeetCode--176--第二高的薪水
问题描述: 编写一个 SQL 查询,获取 Employee 表中第二高的薪水(Salary) . +----+--------+ | Id | Salary | +----+--------+ | 1 ...
- 51 jquery 节点操作和 bootstrapt
jquery 和 bootstrapt1.jquery each 函数 1.each 循环方式一: 可循环对象: var arr =["alex","deng" ...