随笔分类 -  WCF

Ajax调用WCF报405错误
摘要:环境:jquery1.8.1+Wcf(IIS托管)错误:405错误(方法不被允许)原因:ajax跨域调用错误解决办法:1.在发布WCF上面允许crossDomainScriptAccessEnabled<system.serviceModel> <behaviors> <endpointBehaviors> <behavior name="JSONPAspNetAjaxBehavior"> <enableWebScript /> </behavior> ... 阅读全文

posted @ 2013-05-13 13:55 ~紫鱼~ 阅读(3043) 评论(0) 推荐(0)

http改成https wcf 配置更改
摘要:最近有个内部系统要对外公开,要开启https ,所有模块都正常运行,但偏偏服务层出问题了。The HttpGetEnabled property of ServiceMetadataBehavior is set to true and the HttpGetUrl property is a relative address, but there is no http base address. Either supply an http base address or set HttpGetUrl to an absolute address.从上面的字面告诉我们,元数据被设置true . 阅读全文

posted @ 2013-05-03 17:17 ~紫鱼~ 阅读(1649) 评论(0) 推荐(0)

MVC调用SVC无法找到资源解决问题
摘要:我们在.NET 4.0当中调用JS+WCF 一般都是这样做: <system.serviceModel> <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" > <serviceActivations> <add relativeAddress="OrderGetService.svc" service="OrderGetService" 阅读全文

posted @ 2013-04-01 11:19 ~紫鱼~ 阅读(429) 评论(0) 推荐(0)

Ioc系列之Ninject高级使用与webapi调用(普通版)
摘要:我有一组产品 我要获取总价,一般正常情况都是使用设计模式之策略模式来搞定,非常简单。但我们这里要Ioc工具-Ninject,那我们就得写很多接口了。 /// <summary> /// 正常价格 /// </summary> public interface INormal { /// <summary> /// 返回价格总数 /// </summary> /// <param name="products"></param> /// <returns></returns> de 阅读全文

posted @ 2013-03-04 18:59 ~紫鱼~ 阅读(1749) 评论(2) 推荐(0)

WCF系列之.net(4.0) 在网站使用Js调用Wcf Rest
摘要:上一篇,我们介绍了如何使用JS去调用WCF。但实际开发中,各大网站的API都是REST风格,那我们也REST下,顺便用JS调用。废话不多说,我就把几个比较重要的代码贴下:接口:using System.ServiceModel;using System.ServiceModel.Web;[ServiceContract]public interface IproductService{ [WebGet(UriTemplate = "all", ResponseFormat = WebMessageFormat.Json)] //不设置这个 默认就是xml IEnumerab 阅读全文

posted @ 2013-02-28 13:34 ~紫鱼~ 阅读(2929) 评论(1) 推荐(1)

WCF系列之.net(4.0) 在网站使用Js调用Wcf
摘要:上一篇,我们介绍使用WCF代替传统的WebService. 那么代替的话 我们客户端用JS也应该可以调用。.net4.0中我们不仅可以调用,还可以很简单的调用。代码如下:服务端:using System.ServiceModel.Activation; //这个告诉我们是否动态加载ServiceHost宿主//要以IIS管道运行WCF服务 只需要加上这个特性就可以 运行网站的同时 运行WCF服务 AJAX也可以请求到了[AspNetCompatibilityRequirements(RequirementsMode=AspNetCompatibilityRequirementsMode.All 阅读全文

posted @ 2013-02-28 10:31 ~紫鱼~ 阅读(6781) 评论(3) 推荐(0)

WCF系列之.net(4.0) 在网站使用Wcf 代替传统的WebService
摘要:大家在开发webform的时候webService 一直什么拿手好戏。但.net4.0 出现以后,我们完全可以用Wcf 代替传统的WebService.跟我们平时一样引用webservice一样,引用Wcf 服务。我们还是 按 服务接口-》服务-》客户端服务接口:using System;using System.Collections.Generic;using System.Runtime.Serialization;using System.ServiceModel;using System.Text;/* *顺便说下 这里的NameSpace 必须和数据契约的NameSpace一致 否 阅读全文

posted @ 2013-02-27 13:55 ~紫鱼~ 阅读(3404) 评论(1) 推荐(2)

WCF系列之.net(4.0)使用示例
摘要:上两篇,我们介绍了.net3.5 使用WCF一些配置,但到了.NET4.0版本以后,使用WCF就更加简洁了。简洁在那里,当然这服务端的ABC配置,新的特性可以使用默认特性,我们无需再写ABC配置了,如果有意外到是可以配置的。服务端代码如下:using System.ServiceModel;using Wcf.IProductService;namespace Server{ class Program { static void Main(string[] args) { //这里就利用.net4.0 新特性 使用默认总结点 不用... 阅读全文

posted @ 2013-02-27 09:47 ~紫鱼~ 阅读(1163) 评论(0) 推荐(0)

WCF系列之.net(3.0/3.5)Rest使用示例
摘要:上面我介绍了在.NET(3.0/3.5)开发WCF的使用示例。这篇,我将讲解Rest 这个炙手可热的新的开发方式,至于rest 是什么,请大家百度下。我们还是以下面的方式做示例:服务接口-》服务-》客户端1.服务接口:数据接口using System.ServiceModel;using System.ServiceModel.Web; //这里就是REST 要关键引用的类using System.Runtime.Serialization;namespace Wcf.IProductService{ [ServiceContract] public interface IProd... 阅读全文

posted @ 2013-02-25 13:18 ~紫鱼~ 阅读(1441) 评论(0) 推荐(0)

WCF系列之.net(3.0/3.5)使用示例
摘要:WCF目前使用越来越多了,但根据不同的.NET版本,会不同的使用方式。首先,我们在.NET(3.0/3.5)开发WCF的使用示例。服务接口-》服务-》客户端。 也就是最常用的开发方式,也是最多的开发方式。1.服务接口:using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.ServiceModel;namespace WCF.IServiceAPI{ /// <summary> /// 服务接口 /// </summary> [Servi 阅读全文

posted @ 2013-02-23 13:23 ~紫鱼~ 阅读(548) 评论(0) 推荐(0)