WCF wsHttpBinding之Transport security Mode, clientCredentialType=”Basic”
原创地址:http://www.cnblogs.com/jfzhu/p/4071342.html
转载请注明出处
如何在WCF中使用Transport Security Mode,以及如何创建证书,请参见《WCF basicHttpBinding之Transport Security Mode, clientCredentialType="None"》,本文介绍如何使用Basic clientCredentialType。
server web.config
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="wsHttpBindingConfig">
<security mode="Transport">
<transport clientCredentialType="Basic" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service name="WCFDemo.DemoService" behaviorConfiguration="CustomBehavior">
<endpoint address="DemoService" binding="wsHttpBinding" contract="WCFDemo.IDemoService" bindingConfiguration="wsHttpBindingConfig" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"></endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="CustomBehavior">
<serviceMetadata httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
</configuration>
client app.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IDemoService">
<security mode="Transport">
<transport clientCredentialType="Basic" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="https://win-ounm08eqe64.henry.huang/DemoService.svc/DemoService"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IDemoService"
contract="DemoServiceReference.IDemoService" name="WSHttpBinding_IDemoService" />
</client>
</system.serviceModel>
</configuration>
public partial class Form1 : Form
{
DemoServiceReference.DemoServiceClient demoServiceClient; public Form1()
{
InitializeComponent();
demoServiceClient = new DemoServiceReference.DemoServiceClient();
demoServiceClient.ClientCredentials.UserName.UserName = "alex";
demoServiceClient.ClientCredentials.UserName.Password = "";
} private void buttonCalculate_Click(object sender, EventArgs e)
{
try
{
textBoxResult.Text = demoServiceClient.Divide(Convert.ToInt32(textBoxNumerator.Text), Convert.ToInt32(textBoxDenominator.Text)).ToString();
}
catch (FaultException<DemoServiceReference.DivideByZeroFault> fault)
{
MessageBox.Show(fault.Detail.Error + " - " + fault.Detail.Detail);
}
}
}
调用成功。
WCF wsHttpBinding之Transport security Mode, clientCredentialType=”Basic”的更多相关文章
- WCF basicHttpBinding之Transport Security Mode, clientCredentialType="None"
原创地址:http://www.cnblogs.com/jfzhu/p/4071342.html 转载请注明出处 前面文章介绍了<WCF basicHttpBinding之Message Sec ...
- WCF basicHttpBinding之Message Security Mode
原创地址:http://www.cnblogs.com/jfzhu/p/4067873.html 转载请注明出处 前面的文章<WCF Security基本概念>介绍了WCF的securit ...
- iOS App 不支持http协议 App Transport Security has blocked a cleartext HTTP (http://)
目前iOS已经不支持http协议了,不过可以通过info.plist设置允许 App Transport Security has blocked a cleartext HTTP (http://) ...
- App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file
ios进行http请求,会出现这个问题: App Transport Security has blocked a cleartext HTTP (http://) resource load sin ...
- App Transport Security has blocked a cleartext HTTP (http://)
使用SDWebImage加载“http://”开头的图片报错,错误如下: App Transport Security has blocked a cleartext HTTP (http://) r ...
- iOS9中的App Transport Security
问题:webView加载网页加载不出来 原因:苹果在iOS9 sdk中加入了App Transport Security限制(iOS9以前的iOS sdk默认关闭ATS),默认强制使用https,并且 ...
- 网络请求报错:The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.
iOS9引入了新特性App Transport Security (ATS).详情:App Transport Security (ATS) 如果你想设置不阻止任何网络,只需要在info.plist文 ...
- IOS开发 App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file.
xcode自7后不再使用http,而是使用https请求,但目前很多网络请求还只是以http请求,我们可以这样解决 info.plist->添加@“App Transport Security ...
- App Transport Security has blocked a cleartext
错误描述: App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecu ...
随机推荐
- Addthis
WordPress外贸主题模版可以非常方便地整合国外流行的分享收藏社会化网络功能,比如Addthis是国外一个网络书签按钮聚合网站,是稳步提升网站流量和搜索引擎排名的WEB2.0工具!通过AddThi ...
- Go语言 获取get、post参数
在贴代码之前如果能先理解一下golang http.request的三个属性Form.PostForm.MultipartForm应该能较好的理解代码,下面摘录一下. 以上简要翻译一下: Form:存 ...
- Puppet自动化部署-前期环境准备(2)
在安装Puppet环境之前需要配置好机器的基本配置,如规范网络地址IP.hostname,certname认证名称,ntp时间同步等配置完毕,完善的搭建自动化环境. 1.环境介绍 此处实现部署的环境是 ...
- btrace使用
btrace使用 目录btracee是btrace的解压目录 btrace/btrace是btrace的项目工程 root@ubuntu:/usr/local/bogon/btrace# tree b ...
- Linux内核笔记--深入理解文件描述符
内核版本:linux-2.6.11 文件描述符(file descriptor)在Linux编程里随处可见,设备读写.网络通信.进程通信,fd可谓是关键中的关键. 深入理解可以增加我们使用它的信心. ...
- 简述HTML DOM及其节点分类
在JavaScript中,document这个对象大家一定很熟悉,哪怕是刚刚开始学习的新人,也会很快接触到这个对象.而document对象不仅仅是一个普通的JavaScript内置对象,它还是一个巨大 ...
- [Android] Shape背景制作半圆或半边框
实现原理使用layer-list对shape进行叠加显示. 直接上代码: <layer-list xmlns:android="http://schemas.android.com/a ...
- Log4Net异常日志记录在asp.net mvc3.0的应用
前言 log4net是.Net下一个非常优秀的开源日志记录组件.log4net记录日志的功能非常强大.它可以将日志分不同的等级,以不同的格式,输出到不同的媒介.本文主要是简单的介绍如何在Visual ...
- Python 爬虫4——使用正则表达式筛选内容
之前说过,使用urllib和urllib2,只是为了获取指定URL的html内容,而对内容进行解析和筛选,则需要借助python中的正则表达式来完成. 一.预备知识: 1.正则表达式简述: 什么是正则 ...
- STM32之DMA+ADC
借用小甲鱼的经典:各位互联网的广大网友们.大家早上中午晚上好..(打下小广告,因为小甲鱼的视频真的很不错).每次看小甲鱼的视频自学都是比较轻松愉快的..我在想,如果小甲鱼出STM32的视频,我会一集不 ...