<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    精彩的人生

    好好工作,好好生活

    BlogJava 首頁 新隨筆 聯系 聚合 管理
      147 Posts :: 0 Stories :: 250 Comments :: 0 Trackbacks

    #

    六度分割是這樣的理論:所謂六度分割理論是指six degrees of separation,是在20世紀60年代由哈佛大學心理學家 stanley milgram提出的,six degrees of separation,六度分割。簡單來說,六度分割就是在這個社會里,任何兩個人之間建立一種聯系,最多需要六個人(包括這兩個人在內),無論這兩個人是否認識,生活在地球的任何一個地方,他們之間只有六度分割。

    第一次聽說六度理論的時候大約在一年以前,聽說后沒有多久,就參加了朋友火炬的“
    后來,我們發現了越來越多的SNS網站,他們的旗號都是遵循六度的原則,開始都讓我們很興奮,一個階段里面我們幾乎實驗了能看到的所有的SNS網站,然而最后我們都離開了這些網站。他們沒有給我們帶來任何的便捷和好處。這讓我一再反思六度理論。

    再后來,在365kit上線之后,我很久沒見的朋友LLF非常興奮的認為365kit是實現六度思想的一個很好的載體,我們在msn上面進行了簡單的討論,發現大家有很多不太相同的看法,于是相約在七夕之夜,邊吃邊聊。長談之后,LLF接受了我的很多觀點,并說收益匪淺。然而在我看來,他對我啟發也良多,尤其是那天我們說過的東西,是我思索了很久的,但是一直沒有機會串連在一起的東西,我們的長談讓我思維中很多零碎的東西變得更加條理化,所以這篇文章很大一部份要歸功于他。

    特別需要說明的是,本文不是在說明六度是錯誤的理論,而是在討論,在我們的SNS實踐中,六度是不是完整的可以作為指導的思想。我的看法是六度作為SNS的指導原則,并不足夠,還有很多殘缺,這些殘缺會給我們的SNS實踐帶來失敗的結果。

    1、殘缺的六度

    六度雖然是個社會學的理論,但是實際上它更像一個數學理論,很多人說六度和四色問題有異曲同工之妙。在我看來,六度理論很好的闡述了在一個網狀結構(我們的人類社會)下,不同節點之間的聯系和連接關系,然而它并不完整,并不足以指導我們的實踐。

    (1)關系的強弱——權值問題
    首先六度肯定了人與人之間的普遍聯系,但是沒有對這種聯系作定量分析。我們一生可能會認識千百人,他們有的對我極其重要,有的對我無足輕重,我們聯系的建立的原因和方法也是千差萬別,有父母親屬這類生而固有的聯系,也有因為地理位置接近發展出來的,如鄰里關系,還有因為共同學習生活而發展出來的同學、同事關系。六度理論中只把他們統統歸結于聯系,沒有強弱之分。在網狀結構里面,人與人的關系,需要加權處理,在這里,六度是殘缺的。

    (2)到達和建立聯系的區別——目的和結果問題
    20世紀60年代,耶魯大學的社會心理學家米爾格蘭姆(Stanley Milgram)就設計了一個連鎖信件實驗。他將一套連鎖信件隨機發送給居住在內布拉斯加州奧馬哈的160個人,信中放了一個波士頓股票經紀人的名字,信中要求每個收信人將這套信寄給自己認為是比較接近那個股票經紀人的朋友。朋友收信后照此辦理。最終,大部分信在經過五、六個步驟后都抵達了該股票經紀人。六度分割(也叫“六度空間”)的概念由此而來。這個故事很多六度的愛好者都知道,并奉為圣經。但是我請大家注意這個故事和我們現在流行的SNS網站的理念的重要查別。在這個故事里面,信到達了波士頓股票經紀人手里面沒錯,但是請注意整個過程中,每個人的朋友關系都沒有發生改變。對,這點很重要,這個故事里面傳遞的信息,而我們現在看到的SNS網站希望在用戶之間傳遞的是什么呢?是聯系方式是朋友關系。
    說到這里想提一下前面提到的火炬的買車票的實驗,在那個實驗里面,傳遞的實際上也是信息,而不是朋友關系。

    (3)傳遞的成本和激勵——阻尼問題
    在Stanley Milgram的實驗和火炬的實驗里面,都沒有任何的花費,或者說看起來成本為0。但是是不是真的成本為0呢?每個人傳遞一下信件花費極低,改下msn名字更是沒有成本,然而那些人肯這么做,其實是看著朋友的面子上,所以這里花費的成本實際是什么呢?是中國人說的人情債,所謂的關系成本。沒有人喜歡一個整天都要人幫忙這幫忙那的人,人情債和金錢債一樣,背了就一定要還,這就是傳遞中的成本問題。火炬的火車實驗后,我們一直在想這個問題,今天我們急需車票,可以請朋友們改他們的名字,但是我們能不能天天都用這種方法來找人幫忙呢?今天買車票,明天買球票,也許一次兩次可以,次數多了,朋友們肯定會覺得厭煩,甚至放棄你這個朋友。

    Gmail的邀請方式直至今日仍被很多人稱頌,剛剛出現的時候,一個邀請甚至可以賣到60美金。很多人驚呼這是最偉大的營銷。然而,到了今天,很多人的邀請已經變得無法送出去。為什么呢?因為一開始的時候Gmail是稀缺物品,所以價值高昂,加上Gmail帶有Google的強勢品牌和高度用戶認同感,所以就更加被追捧,擁有Gmail成了榮譽的象征。這是這種榮譽成為了Gmail邀請在六度網絡中瘋狂傳播的激勵。然而隨著Gmail的高度普及,這種榮譽感逐步下降,最終降低了激勵,從來使傳播陷入了停滯狀態。

    阻尼是好還是壞?沒有阻尼我們可以給任何人發送信息,每個SNS網站都在宣揚你只需要六度就可以認識克林頓可以認識蓋茨,但是有幾個人真的去認識他們了?是因為他們不值得認識么?不是,是因為聯系雖然看起來只有六度,然而每度的阻尼都有可能都是無法跨越的。但是你不要悲觀,如果沒有阻尼也許你會更加不爽!LLF算過“舉例來說吧。假設每個人有30個朋友,信息經過六度是30的6次方 =729000000,數量足夠到達一個能夠覆蓋所有可能的人的級別。”,如果六度的連接沒有任何的阻尼,估計我們每天收到的來自六度好友的各種各樣的信息就會讓我們的腦袋爆炸。

    在我們的生活里面,一個身份越高的人,越有名的人他就會有越多的好友,于是他也就越不想隨便拓展自己的關系圈子,因為他們往往不勝其擾。前些日子的600演藝名人聯系方式泄露事件就是一個例子,本來我們作為社會一分子都和這600名人有著六度的聯系,然而某天因為他們的聯系方式被公開,他們和我們的聯系立刻被扁平化變成了一度。一瞬間,阻尼消失了,你可以隨便打電話給那英、田震了,你不是想跟馮小剛聊電影么?你現在可以打電話了。但是,我們只能說結果這成了一場災難,很多名人訴苦,說很多人打電話到他們的家里,說了句“你是XXX么?我很喜歡你!”然后就掛了電話。很多人不堪其擾停了機,甚至換了號。

    這場災難對我們這些局外人來說是一個很有意思的故事,很有趣的一點在于此,一旦這些名人和大眾的關系扁平化后(六度變成一度),他們對大眾的價值也開始流失,大眾們只能打電話過去,問一聲,然后炫耀自己給明星打過電話,僅此而已。這個巨大的扁平化工程并沒有擴展追星族們的朋友圈子,他們仍舊離那些明星很遠……

    (4)朋友的朋友是朋友的假設——關系的方向和傳遞問題
    ?SNS網站最愛說的一句話也許就是“朋友的朋友是朋友”,然而那天我跟LLF在Msn聊天的時候就說過這個問題,我認識的某A的朋友某B是我非常反感的一個家伙,而且我的朋友里面還有個人某C對那個家伙某B更加痛恨。所以在現在的SNS服務里面我是不敢把某A和某C同時引入的,因為他們同時引入后,很可能的結果是某B和某C建立聯系后,開始吵架。

    2年前,我創辦了Mop天津聯盟,開始的時候是蜜月,那時候認識的朋友很多至今還是我很好的朋友,雖然我已經離開天津良久了。然而隨著聯盟的擴大,每次聚會的人數越來越多,關系越來越復雜,我們發現小圈子一旦擴大,人數一多,里面就會出現矛盾。不管我們怎么去努力調和,總是有些人會鬧得不可開交。最后大圈子分化成多個小圈子,然后各自相安無事,然后小圈子擴大,又開始混亂,然后再分裂。這個過程我親身經歷,感受頗深。

    和六度經常提起的還有一個150人原則,這個原則說從人的精力來看,很難管理超過150人的關系。其實我相信這里也是因為好友扁平化的保存在一度空間內過多,容易造成矛盾。150人原則從另一個層面說明我們的社會結構為什么會呈現樹狀體系或著說金子塔結構(樹狀和網狀是觀察點的區別,樹可以看作網的特殊形式,網可以看作包含了樹。),這是我一直想聊的一個問題,但是一直覺得想得還不夠深入,所以這里就不細說了。

    我們把友善關系當作正向,那么敵對關系就是負向。朋友的朋友是朋友的假設是一種幻想,同時和某人有正向關系的兩個人的關系,很有可能是負向的,朋友關系是不能簡單傳遞的。

    文章已經很長了,但是我在這里沒有想提出一種解決方案,只是跟大家聊聊我對六度的看法,希望對大家有啟發,也希望大家的意見能給我啟示,后面有時間也許會聊聊我對現有SNS服務的看法,最近總是很忙,呵呵。

    原文:?http://blog.donews.com/tinyfool/archive/2005/08/16/511891.aspx

    posted @ 2006-09-03 23:47 hopeshared 閱讀(303) | 評論 (0)編輯 收藏

    六度理論傳遞的是什么?

    目前國內SNS網站分為兩種,一是交友,二是商務。

    交友走的是大眾路線,例如yeeyoo等;商務走的是專業路線,例如www.linkist.com等。

    看到有很多的關于sns的評論文章,有贊揚,有批評。

    批評者往往抓住六度理論中節點之間的系數問題做文章,應該說這些人對于sns有很好的了解,也有很好的認識。但是他們忽視了一點,就是六度理論節點與節點之間傳遞的是什么的問題。

    在我的理解當中,SNS的節點與節點之間傳遞的是信任,是利益,而不是友誼。所謂的朋友的朋友是朋友,這個是錯誤的。在現實生活中,朋友的朋友通過介紹,相對于陌生人更容易建立起聯系,這就是關系的哲學。但是,這個并不是友誼的直接傳遞,而是信任的傳遞,由信任而結成友誼。

    通過網絡,a認識b,b認識c,a與c之間建立起鏈接,這個要比a直接找c成功率大的多。人與人之間,信任、利益都可能成為朋友的充分必要條件,而這也是SNS網站存在的基礎。

    舉個例子,還是abc,a認識b,b認識c,a想認識c,這中間有兩個傳遞的力量:

    a和b有很好的信任關系,b和c有很好的信任關系,那么a通過b認識c,這個信任是可以傳遞的;

    a和b有利益關系,b和c有利益關系,a為了利益希望認識c,那么b是可以看到預期利益的,也就會幫助a認識c。


    這兩個力量的傳遞是存在組合關系的,因此,也就存在多種可能,并將其傳遞下去。網絡的力量就在于包容一切的力量,在SNS的世界里,并不存在友誼的傳遞,但是存在信任和利益的傳遞。SNS的六度理論也是建立在這個的基礎上,而不是友誼的基礎。a是b的朋友,b是c的朋友,c是d的朋友,但d不一定和a能夠成為朋友。

    SNS的意義在于,通過這一個系統,你可以鏈接到你想認識的人。還是打個比方:

    a想認識h,通過SNS他可以通過b認識h,也可以通過c-d認識h,也可以通過e-f-g認識h,有三個途徑的選擇,而途徑的選擇取決于兩個因素,一是路徑的距離,二是節點之間的鏈接系數。

    無法否認的是,SNS的六度理論是建立在弱鏈接的基礎上的,但由于存在信任和利益等影響因素,這個弱鏈接是可以傳遞的,并且有多種傳遞的可能性。

    以上是看了笨貍《“關系”和SNS》http://blog.donews.com/banly/archive/2005/09/01/535403.aspx?之后的一些想法,與笨貍先生討論。

    原文:http://blog.donews.com/writerrr/archive/2005/09/01/536231.aspx

    posted @ 2006-09-03 23:44 hopeshared 閱讀(356) | 評論 (0)編輯 收藏

    小時候聽說洋鬼子來中國做生意會水土不服,因為他們不懂什么叫做“關系”。現在看到不少國人,居然學習著SNS,看來關于“關系”,鬼子不但已經懂,還開始讓我們反過來去學。

    一開始我以為“關系”是1.0,而SNS是2.0,很是敬佩,學了半天一度六度,發現SNS其實很膚淺,完全不如“關系”這種1.0的東西。

    “關系”很簡單,完全東方式,只可意會無法言傳。一定要“定義”它的話,勉強可以說:

    所謂關系,就是圍繞某種利益目的而搭建的價值傳遞載體。

    最多通過六個人,我可以認識拉登,也許,不過絕對是空話。相反,如果我能夠提供百萬個活體炸彈,拉登應該馬上會來找我。這就是“關系”比SNS理論強的地方。

    依稀記得,當年城里只要有了一張二十噸雞爪的批文,這個信息傳遞到我這個不做批文的圈外人手里時,讓我以為城里有了千萬噸的雞爪進口許可。每個人都說他有這個批文,都在找買家。在這個傳遞過程中,信息是不完整和不對稱的,可能中間有人要了其中的10噸,想找另外一個買家來合作。所以,有人說他有5噸,有人說他有15噸。如果我把總量加起來,去兜售千萬噸雞爪的批文,到頭來,會發現只剩下5噸的額度。傳遞鏈條中的每個人,為了保護自己的增量價值,都不可能直接把源頭供出。我不知道SNS理論,如何定義這中間的變量。

    當我曾經在云南看到很多某主席,某參謀長的紙條時,剛出校門的我很興奮,覺得自己離中央真近。不過很快就發現,那些拿著紙條的人,其實很多也都沒有和那個簽名有過任何接觸以及任何信息傳遞,他們也知道不可能,而且一般做完事情就結束掉,以后提都不提。

    在國內,對于那些營造商業圈的SNS模式,我沒有辦法看好,因為缺乏明確的“某種利益目的”。至于做男女交友的,可以看好,因為利益目的很明晰,是性交網。按照這個推理,做商業應用的SNS,只能垂直,比如批文網,證監會網,煤礦網,運營商網等等。這種推論,只有在“關系”這個1.0理論的指導下才能完成。

    SNS錯誤的地方,是犯了西方文明的老毛病,關注人本體,總是說節點。節點根本不重要,重要的是利益目的。比如笨貍這個本體一點用處都沒有,只有當笨貍被任命為局長的時候,參與到利益目的中去了,才能進入“關系”,當笨貍退休或者被雙規,那么一般來說,就在這個“關系”中消失,特例就不討論了。

    SNS是一個個節點和一條條線,所以編織成所謂的社會關系網絡,這種僵硬呆板的理論實在不值得研究。而“關系”是動態的一個個圈,有了某個利益目的中心,就泛一個美麗而秘密的小漣漪,漣漪消失之后,一切都沒有痕跡。

    a通過b找到了c辦成了一個事情,不證明c就是a的二度關系,沒有關系。只有a-b,b-c這兩個小漣漪浮動了一下。

    “關系”是模糊數學,混沌理論范疇的,也是實用的。鞏固原有關系也好,拓展交際圈也好,主要在于“圍繞某種利益目的”,然后忽略掉分享增值價值的所有環節吧。找到利益維系的中心,比找到認識的人更為重要。所以結論是:每個人都是共同利益之下的一度好友。



    cplwj?發表于2005-09-01 10:23 AM??IP: 219.82.107.*
    從”六度交友”理論想到的

    從今年春天開始的對Web2.0的叫囂, 從Web2.0引發的對網絡SNS交友網絡的狂熱, 我們想到了很多. 現在到了該坐下來冷靜思考的時候了.

    一, 老生常談的”六度理論”更多的是個數學理論

    關于”六度理論”, 最近在互聯網上多有描述, 這里不再贅述. 本人認為, “六度理論”與其說是一個社會學理論或心理學理論, 還不如把它歸類為一個以數學理論為主而略具社會學或心理學特征的理論. 說它更多的具有的是數學理論的特性, 因為根據“六度分隔法”(Six degrees of separation)事實上可以將世界上的所有人聯系起來。事實上,如果網絡中的每個人都能新結識100個朋友,那么他們每人將擁有100萬個“三度朋友”;如果再增加“兩度”的話,整個個人關系網絡的人數將超過全球人口。難怪乎, 有人說, 我們可以通過”六度理論””結識”克林頓和比爾蓋茨.

    二. “弱聯系”在SNS交友網絡和現實生活中的區別.

    “六度理論”中極力推崇的”弱聯系”或稱”弱連接”在人類人際交往中的作用. 我初次接觸這一說法的時候曾經興奮過一陣子, 認為SNS網絡似乎真的在為我們提供一個快速便捷的社交平臺. 后來一細想, 網絡社交平臺上的”弱連接”在互聯網低成本高效率的背后無法真正達到”弱連接”本來應該具有的作用. 讓我們回到現實社會,想一想這個弱連接是如何發揮作用. 比如我找到一個一度的朋友幫忙要解決某個問題, 一度朋友不能解決這個問題, 于是乎他便打電話給他的二度朋友, 二度朋友可能再向三度朋友傳遞, 結果問題在三度朋友手上給解決了. 其實我跟這個”三度”完全是有一種微弱的關系維系著的. 但是由于這種”微弱關系”有了一層接一層的”打電話”的”加固”, 使得現實生活中的我們頻頻受惠于這”微弱關系”. 但請記住, 現實生活中的加固”微弱關系”的”打電話”的過程, 其實其成本是很高的. 這就是中國人通常所說的”人情債”, 這個成本是無法以金錢計算的.

    讓我們再回到SNS網絡里提到的”微弱關系”, 這個微弱關系似乎可以通過互聯網的低成本優勢得以”加固”, 但是實際上這種通過”搜索”朋友圈里的聯系人的看似低成本的方法, 它根本無法實現現實生活中的加固微弱關系的作用, 它反而成了對朋友的騷擾. 所以任何想”低成本”的加固”微弱關系”的嘗試最終將是徒勞的.

    三. 六度關系中傳遞的什么?

    六度理論中宣稱我們可以通過”朋友的朋友”認識可靠的朋友. 這個理論聽起來似乎沒錯. 20 世紀60年代,耶魯大學的社會心理學家米爾格蘭姆(Stanley Milgram)就設計了一個連鎖信件實驗。他將一套連鎖信件隨機發送給居住在內布拉斯加州奧馬哈的160個人,信中放了一個波士頓股票經紀人的名字,信中要求每個收信人將這套信寄給自己認為是比較接近那個股票經紀人的朋友。朋友收信后照此辦理。最終,大部分信在經過五、六個步驟后都抵達了該股票經紀人。六度理論(也叫“六度空間””六度分割”)的概念由此而來。這個故事很多六度的愛好者都知道,并奉為圣經。但是我請大家注意這個故事和我們現在流行的SNS網站的理念的重要區別。在這個故事里面,信到達了波士頓股票經紀人手里面沒錯,但是請注意整個過程中,每個人的朋友關系都沒有發生改變。這個故事里面傳遞的信息,而我們現在看到的SNS網站希望在用戶之間傳遞的是什么呢?是聯系方式是朋友關系。但這個試驗中傳遞的實際上是信息而已,而不是朋友關系。這也就是我們通過六度理論可以把”信息”傳遞給克林頓, 而無法打電話給老克一起共進早餐的原因.通過”六度”是無法傳遞”友情”的. 友誼和友情是有限的人群在親密和共識的基礎上建立起來的。一個真正的社交網絡狹小而封閉:它是一個由欄桿圍起的社區,而不是一個向地平線延伸的大都市。

    四. 150人原則

    上面提到的有限的人群的基礎上的朋友感情, 實際上是個很狹小的空間. 這就是和六度理論一起經常提起的”150人原則”,這個原則說從人的精力來看,很難管理超過150人的關系. 而我們從小學開始成為一個社會人開始, 大都經歷小學, 初中,高中和大學, 然后進入社會從事各類工作. 這么一個過程, 一個人能結識的比較”一度”的朋友也就150個人.當然這個數字隨個人的性格而有差異.

    五. 對”150人”關系管理的缺失

    我們都承認我們有這”150人”的一度關系的存在.但是現實的現狀是, 我們沒有一個人把這個150人的一度關系管理好. 以一個剛剛走入工作崗位的人為例, 我們經歷了各個學習階段, 試問自己, 我們還有幾個人還知道幾個小學同學的聯系方式? 幾個初中同學的聯系方式? 幾個高中同學的聯系方式? 再過五六年, 還有幾個人還能隨時聯系得上大學的同學? 這里有必要提醒大家, 同學友誼是世間最純潔的友誼之一, 它不帶有任何功利的因素. 其實我們的同學, 以及以后認識的同事朋友分布在各行各業, 密切的維護這些關系對我們的事業和生活都已足夠. 而在SNS叫囂下的中國, 似乎只有二度三度甚至五度六度的朋友才是事業成功的基石. 我們在此是大錯了. 新近的 www.LL51.com ”聯絡無憂”通訊錄倒是為我們解決了這個問題. 這是一個簡單的通訊錄工具, 是個互動的工具, 我們不妨可以冠之以”AddressBook2.0”, 這是一個維護”150人”一度朋友的工具. 每個人的聯系方式有很多, 你在充分消除你對”隱私”的憂慮之后, 你只要留給你的一度朋友一個或多個能夠隨時找到你的聯系方式, 如現在經常使用郵址, 如手機號碼, 如QQ, 如MSN等等, 這樣我們就不會間斷和朋友的聯系了!

    羅里羅嗦寫多了. 不妨讓我們從叫囂一陣子了的”六度理論”中走出來, 回到現實中去. 社交網絡讓我們一下子擁有幾千個幾萬個幾十萬個“朋友”短時間內還感覺挺有趣的,但這種快樂最終將逐漸消失。更重要的是, 讓我們管好眼前的朋友, 不要讓培養多年的同學友情, 同事友情在歲月無情的滌蕩中消失在我們的視野.

    lucy@linkist?發表于2005-09-01 10:40 AM??IP: 218.1.194.*
    呵呵,果然是剛出校門不久的社會人 :) 如果你將來走的是從政之路,那么這篇文章非常有道理,SNS對政客確實也沒什么用。如果不小心走了國際化的商業之路,我是不太相信你過10年還象今天這么想。
    “a通過b找到了c辦成了一個事情,不證明c就是a的二度關系,沒有關系。只有a-b,b-c這兩個小漣漪浮動了一下。”
    是不是二度關系并不重要,SNS的精髓也不在于確定a和c之間到底應該是幾度。沒有SNS,a為了找到c,只能一個個電話去詢問所有的朋友,最后也許碰巧發現c能辦事;而有了SNS,a一下就可以找到c了。至于c幫不幫,那是互聯網外的事情了。
    前兩天有個朋友拜托我找人幫他遞個簡歷給Cisco(聽說Cisco對無介紹人的簡歷幾乎不看,也從來不委托獵頭招聘),沒有SNS的話,也許花一年都找不到引薦人…… 你認為還可以用什么方法很快地尋找到介紹人呢?


    原文:http://blog.donews.com/banly/archive/2005/09/01/535403.aspx


    posted @ 2006-09-03 23:42 hopeshared 閱讀(1023) | 評論 (0)編輯 收藏

    by Hao He
    August 11, 2004

    Despite the lack of vendor support, Representational State Transfer (REST) web services have won the hearts of many working developers. For example, have both SOAP and REST interfaces, and 85% of the usage is on the REST interface. Compared with other styles of web services, REST is easy to implement and has many highly desirable architectural properties: scalability, performance, security, reliability, and extensibility. Those characteristics fit nicely with the modern business environment, which commands technical solutions just as adoptive and agile as the business itself.

    A few short years ago, REST had a much lower profile than XML-RPC, which was much in fashion. Now XML-RPC seems to have less mindshare. People have made significant efforts to RESTize SOAP and WSDL. The question is no longer whether to REST, but instead it's become how to be the best REST?

    The purpose of this article is to summarize some best practices and guidelines for implementing RESTful web services. I also propose a number of informal standards in the hope that REST implementations can become more consistent and interoperable.

    The following notations are used in this article:

    1. BP: best practice
    2. G: general guideline
    3. PS: proposed informal standard
    4. TIP: implementation tip
    5. AR: arguably RESTful -- may not be RESTful in the strict sense

    Reprising REST

    Let's briefly reiterate the REST web services architecture. REST web services architecture conforms to the W3C's Web Architecture, and leverages the architectural principles of the Web, building its strength on the proven infrastructure of the Web. It utilizes the semantics of HTTP whenever possible and most of the principles, constraints, and best practices published by the TAG also apply.

    The REST web services architecture is related to the Service Oriented Architecture. This limits the interface to HTTP with the four well-defined verbs: GET, POST, PUT, and DELETE. REST web services also tend to use XML as the main messaging format.

    [G] Implementing REST correctly requires a resource-oriented view of the world instead of the object-oriented views many developers are familiar with.

    Resource

    One of the most important concepts of web architecture is a "resource." A resource is an abstract thing identified by a URI. A REST service is a resource. A service provider is an implementation of a service.

    URI Opacity [BP]

    The creator of a URI decides the encoding of the URI, and users should not derive metadata from the URI itself. URI opacity only applies to the path of a URI. The query string and fragment have special meaning that can be understood by users. There must be a shared vocabulary between a service and its consumers.

    Query String Extensibility [BP, AR]

    A service provider should ignore any query parameters it does not understand during processing. If it needs to consume other services, it should pass all ignored parameters along. This practice allows new functionality to be added without breaking existing services.

    [TIP] XML Schema provides a good framework for defining simple types, which can be used for validating query parameters.

    Deliver Correct Resource Representation [G]

    A resource may have more than one representation. There are four frequently used ways of delivering the correct resource representation to consumers:

    1. Server-driven negotiation. The service provider determines the right representation from prior knowledge of its clients or uses the information provided in HTTP headers like Accept, Accept-Charset, Accept-Encoding, Accept-Language, and User-Agent. The drawback of this approach is that the server may not have the best knowledge about what a client really wants.
    2. Client-driven negotiation. A client initiates a request to a server. The server returns a list of available of representations. The client then selects the representation it wants and sends a second request to the server. The drawback is that a client needs to send two requests.
    3. Proxy-driven negotiation. A client initiates a request to a server through a proxy. The proxy passes the request to the server and obtains a list of representations. The proxy selects one representation according to preferences set by the client and returns the representation back to the client.
    4. URI-specified representation. A client specifies the representation it wants in the URI query string.

    Server-Driven Negotiation [BP]

    1. When delivering a representation to its client, a server MUST check the following HTTP headers: Accept, Accept-Charset, Accept-Encoding, Accept-Language, and User-Agent to ensure the representation it sends satisfies the user agent's capability.
    2. When consuming a service, a client should set the value of the following HTTP headers: Accept, Accept-Charset, Accept-Encoding, Accept-Language, and User-Agent. It should be specific about the type of representation it wants and avoid "*/*", unless the intention is to retrieve a list of all possible representations.
    3. A server may determine the type of representation to send from the profile information of the client.

    URI-Specified Representation [PS, AR]

    A client can specify the representation using the following query string:

    mimeType={mime-type}

    A REST server should support this query.

    Different Views of a Resource [PS, AR]

    A resource may have different views, even if there is only one representation available. For example, a resource has an XML representation but different clients may only see different portion of the same XML. Another common example is that a client might want to obtain metadata of the current representation.

    To obtain a different view, a client can set a "view" parameter in the URI query string. For example:

    
    GET http://www.example.com/abc?view=meta

    where the value of the "view" parameter determines the actual view. Although the value of "view" is application specific in most cases, this guideline reserves the following words:

    1. "meta," for obtaining the metadata view of the resource or representation.
    2. "status," for obtaining the status of a request/transaction resource.

    Service

    A service represents a specialized business function. A service is safe if it does not incur any obligations from its invoking client, even if this service may cause a change of state on the server side. A service is obligated if the client is held responsible for the change of states on server side.

    Safe Service

    A safe service should be invoked by the GET method of HTTP. Parameters needed to invoke the service can be embedded in the query string of a URI. The main purpose of a safe service is to obtain a representation of a resource.

    Service Provider Responsibility [BP]

    If there is more than one representation available for a resource, the service should negotiate with the client as discussed above. When returning a representation, a service provider should set the HTTP headers that relate to caching policies for better performance.

    A safe service is by its nature idempotent. A service provider should not break this constraint. Clients should expect to receive consistent representations.

    Obligated Services [BP]

    Obligated services should be implemented using POST. A request to an obligated service should be described by some kind of XML instance, which should be constrained by a schema. The schema should be written in W3C XML Schema or Relax NG. An obligated service should be made idempotent so that if a client is unsure about the state of its request, it can send it again. This allows low-cost error recovery. An obligated service usually has the simple semantic of "process this" and has two potential impacts: either the creation of new resources or the creation of a new representation of a resource.

    Asynchronous Services

    One often hears the criticism that HTTP is synchronous, while many services need to be asynchronous. It is actually quite easy to implement an asynchronous REST service. An asynchronous service needs to perform the following:

    1. Return a receipt immediately upon receiving a request.
    2. Validate the request.
    3. If the request if valid, the service must act on the request as soon as possible. It must report an error if the service cannot process the request after a period of time defined in the service contract.

    Request Receipt

    An example receipt is shown below:

    <receipt xmlns="http://www.xml.org/2004/rest/receipt" requestUri = "http://www.example.com/xya343343" received = "2004-10-03T12:34:33+10:00">
    ??<transaction uri="http://www.example.com/xyz2343" status = "http://www.example.com/xyz2343?view=status"/>
    </receipt>

    A receipt is a confirmation that the server has received a request from a client and promises to act on the request as soon as possible. The receipt element should include a received attribute, the value of which is the time the server received the request in WXS dateTime type format. The requestUri attribute is optional. A service may optionally create a request resource identified by the requestUri. The request resource has a representation, which is equivalent to the request content the server receives. A client may use this URI to inspect the actual request content as received by the server. Both client and server may use this URI for future reference.

    However, this is application-specific. A request may initiate more than one transaction. Each transaction element must have a URI attribute which identifies this transaction. A server should also create a transaction resource identified by the URI value. The transaction element must have a status attribute whose value is a URI pointing to a status resource. The status resource must have an XML representation, which indicates the status of the transaction.

    Transaction

    A transaction represents an atomic unit of work done by a server. The goal of a transaction is to complete the work successfully or return to the original state if an error occurs. For example, a transaction in a purchase order service should either place the order successfully or not place the order at all, in which case the client incurs no obligation.

    Status URI [BP, AR]

    The status resource can be seen as a different view of its associated transaction resource. The status URI should only differ in the query string with an additional status parameter. For example:

    Transaction URI: http://www.example.com/xyz2343 Transaction Status URI: http://www.example.com/xyz2343?view=status

    Transaction Lifecycle [G]

    A transaction request submitted to a service will experience the following lifecycle as defined in Web Service Management: Service Life Cycle:

    1. Start -- the transaction is created. This is triggered by the arrival of a request.
    2. Received -- the transaction has been received. This status is reached when a request is persisted and the server is committed to fulfill the request.
    3. Processing -- the transaction is being processed, that is, the server has committed resources to process the request.
    4. Processed -- processing is successfully finished. This status is reached when all processing has completed without any errors.
    5. Failed -- processing is terminated due to errors. The error is usually caused by invalid submission. A client may rectify its submission and resubmit. If the error is caused by system faults, logging messages should be included. An error can also be caused by internal server malfunction.
    6. Final -- the request and its associated resources may be removed from the server. An implementation may choose not to remove those resources. This state is triggered when all results are persisted correctly.

    Note that it is implementation-dependent as to what operations must be performed on the request itself in order to transition it from one status to another. The state diagram of a request (taken from Web Service Management: Service Life Cycle) is shown below:

    The state diagram of a request (taken from Web Service Management: Service Life Cycle)

    As an example of the status XML, when a request is just received:

    <status state="received" timestamp="2004-10-03T12:34:33+10:00" />

    The XML contains a state attribute, which indicates the current state of the request. Other possible values of the state attribute are processing, processed, and failed.

    When a request is processed, the status XML is (non-normative):

    <status state="processed" timestamp="2004-10-03T12:34:33+10:00" >
    ??<result uri="http://example.com/rest/1123/xyz" />
    </status>

    This time, a result element is included and it points to a URL where the client can GET request results.

    In case a request fails, the status XML is (non-normative):

    
    <status   state="failed" timestamp="2002-10-03T12:34:33+10:00" >
      <error code="3" >
        <message>A bad request. </message>
        <exception>line 3234</exception>
      </error>
    </status>

    A client application can display the message enclosed within the message tag. It should ignore all other information. If a client believes that the error was not caused by its fault, this XML may serve as a proof. All other information is for internal debugging purposes.

    Request Result [BP]

    A request result view should be regarded as a special view of a transaction. One may create a request resource and transaction resources whenever a request is received. The result should use XML markup that is as closely related to the original request markup as possible.

    Receiving and Sending XML [BP]

    When receiving and sending XML, one should follow the principle of "strict out and loose in." When sending XML, one must ensure it is validated against the relevant schema. When receiving an XML document, one should only validate the XML against the smallest set of schema that is really needed. Any software agent must not change XML it does not understand.

    An Implementation Architecture

    An Implementation Architecture

    The architecture represented above has a pipe-and-filter style, a classical and robust architectural style used as early as in 1944 by the famous physicist, Richard Feynman, to build the first atomic bomb in his computing team. A request is processed by a chain of filters and each filter is responsible for a well-defined unit of work. Those filters are further classified as two distinct groups: front-end and back-end. Front-end filters are responsible to handle common Web service tasks and they must be light weight. Before or at the end of front-end filters, a response is returned to the invoking client.

    All front-end filters must be lightweight and must not cause serious resource drain on the host. A common filter is a bouncer filter, which checks the eligibility of the request using some simple techniques:

    1. IP filtering. Only requests from eligible IPs are allowed.
    2. URL mapping. Only certain URL patterns are allowed.
    3. Time-based filtering. A client can only send a certain number of requests per second.
    4. Cookie-based filtering. A client must have a cookie to be able to access this service.
    5. Duplication-detection filter. This filter checks the content of a request and determines whether it has received it before. A simple technique is based on the hash value of the received message. However, a more sophisticated technique involves normalizing the contents using an application-specific algorithm.

    A connector, whose purpose is to decouple the time dependency between front-end filters and back-end filters, connects front-end filters and back-end filters. If back-end processing is lightweight, the connector serves mainly as a delegator, which delegates requests to its corresponding back-end processors. If back-end processing is heavy, the connector is normally implemented as a queue.

    Back-end filters are usually more application specific or heavy. They should not respond directly to requests but create or update resources.

    This architecture is known to have many good properties, as observed by Feynman, whose team improved its productivity many times over. Most notably, the filters can be considered as a standard form of computing and new filters can be added or extended from existing ones easily. This architecture has good user-perceived performance because responses are returned as soon as possible once a request becomes fully processed by lightweight filters. This architecture also has good security and stability because security breakage and errors can only propagate a limited number of filters. However, it is important to note that one must not put a heavyweight filter in the front-end or the system may become vulnerable to denial-of-service attacks.

    posted @ 2006-08-31 17:26 hopeshared 閱讀(811) | 評論 (0)編輯 收藏

    I am seeing a lot of new web services are implemented using a REST style architecture these days rather than a SOAP one. Lets step back a second and explain what REST is.

    What is a REST Web Service

    The acronym REST stands for Representational State Transfer, this basically means that each unique URL is a representation of some object. You can get the contents of that object using an HTTP GET, to delete it, you then might use a POST, PUT, or DELETE to modify the object (in practice most of the services use a POST for this).

    Who's using REST?

    All of Yahoo's web services use REST, including Flickr, del.icio.us API uses it, pubsub, bloglines, technorati, and both eBay, and Amazon have web services for both REST and SOAP.

    Who's using SOAP?

    Google seams to be consistent in implementing their web services to use SOAP, with the exception of Blogger, which uses XML-RPC. You will find SOAP web services in lots of enterprise software as well.

    REST vs SOAP

    As you may have noticed the companies I mentioned that are using REST api's haven't been around for very long, and their apis came out this year mostly. So REST is definitely the trendy way to create a web service, if creating web services could ever be trendy (lets face it you use soap to wash, and you rest when your tired). The main advantages of REST web services are:

    • Lightweight - not a lot of extra xml markup
    • Human Readable Results
    • Easy to build - no toolkits required

    SOAP also has some advantages:

    • Easy to consume - sometimes
    • Rigid - type checking, adheres to a contract
    • Development tools

    For consuming web services, its sometimes a toss up between which is easier. For instance Google's AdWords web service is really hard to consume (in CF anyways), it uses SOAP headers, and a number of other things that make it kind of difficult. On the converse, Amazon's REST web service can sometimes be tricky to parse because it can be highly nested, and the result schema can vary quite a bit based on what you search for.

    Which ever architecture you choose make sure its easy for developers to access it, and well documented.




    原文:http://www.petefreitag.com/item/431.cfm

    posted @ 2006-08-31 17:21 hopeshared 閱讀(1316) | 評論 (0)編輯 收藏

    僅列出標題
    共30頁: First 上一頁 4 5 6 7 8 9 10 11 12 下一頁 Last 
    主站蜘蛛池模板: 2022免费国产精品福利在线 | 中文字幕亚洲日本岛国片| 亚洲av日韩片在线观看 | 国产亚洲美女精品久久久久| 欧美大尺寸SUV免费| 亚洲无码视频在线| 日本免费网站在线观看| 亚洲成AV人片在线观看| 两个人看的www高清免费观看| 中文字幕不卡亚洲| 国产免费阿v精品视频网址| 亚洲人成电影福利在线播放| 91福利免费视频| 亚洲一区中文字幕在线电影网| 精品香蕉在线观看免费| 亚洲成AⅤ人影院在线观看| 全部一级一级毛片免费看| 很黄很黄的网站免费的| 自拍日韩亚洲一区在线| 日韩精品无码人妻免费视频| 免费无码又爽又黄又刺激网站| 亚洲午夜爱爱香蕉片| 无码人妻一区二区三区免费看| 亚洲精品成人图区| 日韩成人免费aa在线看| 一本一道dvd在线观看免费视频| 国产成A人亚洲精V品无码 | 永久看日本大片免费35分钟| 国产成人精品日本亚洲专一区| 日韩免费a级在线观看| 9久热这里只有精品免费| 亚洲福利视频网站| 免费一级大黄特色大片| 中文字幕免费人成乱码中国| 亚洲日本在线播放| 亚洲 无码 在线 专区| 91久久精品国产免费一区| 亚洲av日韩专区在线观看| 欧美a级在线现免费观看| 免费看一级高潮毛片| 亚洲视频在线免费播放|