自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

如何保護(hù)WCF服務(wù)元數(shù)據(jù)

開發(fā) 開發(fā)工具
我們在本文中以一個(gè)案例來具體分析一下WCF服務(wù)元數(shù)據(jù)的保護(hù)之道,以方便大家理解,希望可以提高大家對于WCF的熟練程度。

WCF服務(wù)元數(shù)據(jù)的保護(hù)方法是一個(gè)比較復(fù)雜的步驟。相信對于初學(xué)者來說,很難操作這一方法。在這里我們就為大家介紹一下相關(guān)方法技巧。#t#

概述

WCF是 Microsoft 為構(gòu)建面向服務(wù)的應(yīng)用程序而提供的統(tǒng)一編程模型(摘自MSDN),在分布式環(huán)境下的安全問題尤為重要,如果你覺得使用了WCF默認(rèn)的安全措施可以讓你高枕無憂,那明天你可就以回家種田了,當(dāng)然,對于學(xué)習(xí)來說,足夠了~,但我們講的是真正的項(xiàng)目應(yīng)用,WCF在各種協(xié)議下的安全提供和保證是不盡相同的。

背景

某天,經(jīng)理老陳對程序員小李說:小李,我們公司外包到一個(gè)項(xiàng)目,但是客戶要求采用分布式部署,現(xiàn)在項(xiàng)目快接近尾聲了,由于我們采用的是WCF,所以在部署的時(shí)候出現(xiàn)了一點(diǎn)問題,我們的服務(wù)好像誰都能訪問得到啊,這是為什么呢?

WCF服務(wù)元數(shù)據(jù)問題呈現(xiàn)

小李***件事就是去查看了服務(wù)配置文件,真的是不看不知道,一看嚇一跳,原來開發(fā)WCF時(shí),采用的都是默認(rèn)的配置,全是自動(dòng)生成的代碼,沒有經(jīng)過任何的改動(dòng),一想到項(xiàng)目將會以這種姿態(tài)交付,小李著實(shí)捏了一把汗。


 

  1. < services> 
  2. < service name="WcfServiceLibrary2.Service1"
     behaviorConfiguration="WcfService
    Library2.Service1Behavior"
    > 
  3. < host> 
  4. < baseAddresses> 
  5. < add baseAddress = "http://
    localhost:8731/Design_Time_Addresses/
    WcfServiceLibrary2/Service1/"
     /> 
  6. < /baseAddresses> 
  7. < /host> 
  8. < endpoint address ="" binding=
    "wsHttpBinding" contract="WcfService
    Library2.IService1"
    > 
  9. < identity> 
  10. < dns value="localhost"/> 
  11. < /identity> 
  12. < /endpoint> 
  13. < endpoint address="mex" binding=
    "mexHttpBinding" contract="IMetadataExchange"/> 
  14. < /service> 
  15. < /services> 
  16. < behaviors> 
  17. < serviceBehaviors> 
  18. < behavior name="WcfServiceLibrary2
    .Service1Behavior"
    > 
  19. < serviceMetadata httpGetEnabled="True"/> 
  20. < serviceDebug includeException
    DetailInFaults
    ="False" /> 
  21. < /behavior> 
  22. < /serviceBehaviors> 
  23. < /behaviors> 

WCF服務(wù)元數(shù)據(jù)解決之道

小李***件事就是把配置文件給修改好了,接著解決了困擾老陳許久的問題。

1、刪除元數(shù)據(jù)交換終結(jié)點(diǎn)信息

  1. < endpoint address="mex" 
    binding="mexHttpBinding" 
    contract="IMetadataExchange"/> 

2、將http協(xié)議獲取元數(shù)據(jù)重置為:false

  1. < serviceMetadata 
    httpGetEnabled="false"/> 

3、一般我們都會在開發(fā)時(shí)配置為WCF服務(wù)元數(shù)據(jù)可發(fā)現(xiàn),但是切記,發(fā)布你的服務(wù)前,一定要?jiǎng)h除了,目前,服務(wù)在一定范圍上得到了保護(hù)

4、最終配置如下

 

  1. < services> 
  2. < service 
  3. name="WcfServiceLibrary2.Service1" 
  4. behaviorConfiguration=
    "WcfServiceLibrary2.Service1Behavior"> 
  5. < host> 
  6. < baseAddresses> 
  7. < add baseAddress = "http://
    localhost:8731/Design_Time_Addresses
    /WcfServiceLibrary2/Service1/"
     /> 
  8. < /baseAddresses> 
  9. < /host> 
  10. < endpoint 
  11. address =""
  12.  binding="wsHttpBinding" 
  13. contract="WcfServiceLibrary2
    .IService1"
    > 
  14. < identity> 
  15. < dns value="localhost"/> 
  16. < /identity> 
  17. < /endpoint> 
  18. < /service> 
  19. < /services> 
  20. < behaviors> 
  21. < serviceBehaviors> 
  22. < behavior name="WcfServiceLibrary2
    .Service1Behavior"
    >   
  23. < serviceDebug includeException
    DetailInFaults
    ="False" /> 
  24. < serviceDebug includeException
    DetailInFaults
    ="False"/>
  25. < /behavior>
  26. < /serviceBehaviors>
  27. < /behaviors> 

以上就是針對WCF服務(wù)元數(shù)據(jù)的一些操作方法介紹。

責(zé)任編輯:曹凱 來源: 博客園
相關(guān)推薦

2009-07-01 09:43:40

WCF安全元數(shù)據(jù)

2009-12-21 16:37:41

WCF獲取服務(wù)元數(shù)據(jù)

2009-11-06 10:01:07

WCF服務(wù)元數(shù)據(jù)

2009-11-09 17:30:20

WCF元數(shù)據(jù)

2009-11-06 10:45:47

WCF服務(wù)元數(shù)據(jù)交換

2009-11-09 16:14:49

WCF服務(wù)元數(shù)據(jù)

2010-02-22 11:02:06

WCF元數(shù)據(jù)

2010-02-24 10:41:28

WCF服務(wù)保護(hù)

2010-02-26 14:12:27

WCF元數(shù)據(jù)

2010-03-02 09:39:11

保護(hù)WCF服務(wù)

2010-03-02 10:50:57

WCF元數(shù)據(jù)交換

2022-07-05 17:49:34

元宇宙安全隱私保護(hù)

2009-11-06 10:37:57

配置WCF服務(wù)

2010-03-01 13:17:46

WCF單向服務(wù)

2012-02-14 10:18:11

WCF數(shù)據(jù)服務(wù)

2024-11-01 10:37:31

2009-11-06 10:25:34

WCF元數(shù)據(jù)交換

2020-10-26 10:17:12

數(shù)據(jù)保護(hù)即服務(wù)DPaaS網(wǎng)絡(luò)安全

2009-11-09 17:17:31

WCF元數(shù)據(jù)交換

2009-12-04 17:47:04

WCF 服務(wù)
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號