MSPL服務器應用程序部署的圖解說明


最近在做Lync相關的開發,剛接觸到MSPL應用程序,MSPL(Microsoft SIP Processing Language)是Lync開發中很重要的一種腳本語言,它屬於Lync Server SDK包,主要用來用來過濾和路由SIP消息。它開發的腳本是嵌在Lync Server 2010應用程序中應用程序清單(manifests)中。MSPL不支持算術運算,類型定義和除foreach外的循環。

本次不講具體的MSPL語法和應用,因為關於MSPL部署的資料比較少,很多剛接觸MSPL開發的朋友,可能和本人一樣,在MSPL應用程序部署的問題花了不少時間。因此,作為預備知識,先講一下怎么部署MSPL應用程序到Lync Server,其實這個過程並不復雜。

我們以SDK中自帶的案例(FilteringApp和Archiver)來做部署說明:

案例一般在C:\Program Files\Microsoft Lync Server 2010\SDK\Samples目錄下,FilteringApp是一個只有腳本(ScriptOnly)的服務器應用程序,Archiver是一個編譯的服務器應用程序。

MSPL服務器應用程序可以部署在以下服務器上:

Standard Edition Server
Director
Front End Server
A/V Conferencing Server
Mediation Server
Edge Server
Archiving Server
Monitoring Server
Archiving and Monitoring Server
Survivable Branch Server

我們先來講ScriptOnly的應用程序FilteringApp的部署

1. 將應用程序目錄FilteringApp復制到服務器上,如C:/lync目錄下,在C:/Lync/FilteringApp目錄上有兩個文件:

   1) Filtering.am 腳本文件(應用程序清單文件,xml格式)

 

View Code
<? xml version="1.0" ?>
< r:applicationManifest
 
r:appUri ="http://www.microsoft.com/LC/SDK/Samples/Filter"
 xmlns:r
="http://schemas.microsoft.com/lcs/2006/05" >

<!--  
  - Handle all IMs
  
-->
< r:requestFilter  methodNames ="ALL"
                 strictRoute
="true"
                 registrarGenerated
="false"
                 domainSupported
="false" />

<!--  
  - Ignore all responses.
  
-->
< r:responseFilter  reasonCodes ="NONE" />

<!--
  - Don't proxy by default.
  
-->
< r:proxyByDefault  action ="false"   />

<!--  
  - Script-only application.
  
-->
< r:scriptOnly />

<!--
  -
  - policy.txt:
  - 
  - The IM policy database file.  Contains three whitespace-delimited
  - columns, formatted as follows:
  -
  -       user@domain     policy   value
  - 
  -  where user@domain is the user's full request-uri, and policy is one
  -  of the following:
  - 
  -       allow: deliver all IMs sent to this user.
  -       filter: deliver all IMs to this user, provided the word in
  -           the value column is not in the message body.
  -       drop: reject all IMs sent to this user.
  -
  
-->
< r:file  name ="policyTable"  path ="policy.txt"  delimitedBy ="whitespace"  keyColumnName ="uri" >
    <!--  Policy applies to this URI.  -->
    < r:column  name ="uri"   />

    <!--  The policy verb describing action to be taken (see above description)  -->
    < r:column  name ="policy"   />

    <!--  The filter string applied to messages (for "filter" policy)  -->
    < r:column  name ="value"   />
</ r:file >

< r:splScript > <![CDATA[

/*++

Copyright (C) 2004 Microsoft Corporation.

Script:

    Filter.am.

Abstract:

    This sample demonstrates a simple user-based IM filtering policy.  The
    policy data is read from a structured flat file;  see above for a 
    description of this file's contents.  Note that the file is reread if
    modified; alternatively, a static="true" attribute in the <file> tag
    changes this behavior.

    Features demonstrated:

    - Flat file access

--*/

thisScript = "Filter.am :: ";

/*
 * Banner
 */
Log("Debug", false, "");
Log("Debug", false, "Entering Filter.am");

Log("Debug", false, "New ", sipRequest.Method, " request for ", GetUserAtHost(sipRequest.To));

/*
 * Get user@domain string for the user in the To: header.
 */
userUri = GetUri(sipRequest.To);
userAtHost = GetUserAtHost(userUri);

/*
 * Look up the policy for this user.
 */
policy = policyTable[userAtHost].policy;

/*
 * Act on the policy verb.
 */
switch (policy)
{
    case "allow":
        /*
         * Proxy this request.
         */
        ProxyRequest("");
        Log("Debug", false, thisScript, "[allow] Proxying ", sipRequest.Method);
        break;

    case "filter":
        /*
         * Proxy this request, if the content body doesn't contain the specified
         * forbidden text.
         */
        if (IndexOfString(sipRequest.Content, policyTable[userAtHost].value) == -1)
        {
            /*
             * Content body doesn't match filter string.  Proxy.
             */
            Log("Debug", false, thisScript, "[filter] Proxying " , sipRequest.Method);
            ProxyRequest("");
        }
        else
        {
            /*
             * Content matched filter string -- reject this request.
             */
            Log("Debug", false, thisScript, "[filter] Rejecting ", sipRequest.Method);
            Respond(403, "Forbidden (Message filtered)");
        }
        break;

    case "drop":
        /*
         * Drop all requests sent to this user.
         */
        Log("Debug", false, thisScript, "[drop] Rejecting ", sipRequest.Method);
        Respond(403, "Forbidden (Message filtered)");
        break;

    default:
        /*
         * Unknown policy verb -- by default, reject
         */
        Log("Debug", false, thisScript, "No policy verb for user ", userAtHost, " -- dropping ", sipRequest.Method);
        Respond(403, "Forbidden (Invalid policy verb)");
        break;
}

]]> </ r:splScript >
</ r:applicationManifest >

其中:r:appUri="http://www.microsoft.com/LC/SDK/Samples/Filter"表示應用程序Uri,在后面的安裝腳本中要用到

   2)Policy.txt,此應用程序中用到內flat file.作用大家看一內容就清楚

 

user1@myhost.com    allow
user2@myhost.com    filter          confidential
user3@myhost.com    drop

 

   

2. 在Lync Server命令行管理程序中執行PowerShell的安裝腳本:

 

New-CsServerApplication -Identity  " registrar:lyncserver.corp.itime.biz/FilteringApp " -Uri  http://www.microsoft.com/LCS/Samples/Filtering  -Critical  $False -Enabled  $True -ScriptName  " C:\lync\FilteringApp\Filter.am "

 

 其中:

       registrar:lyncserver.corp.itime.biz/FilteringApp 是要部署的應用程序標識,其中是lyncserver.corp.itime.biz服務器的FQDN,FilteringApp 是應用程序名稱,應修改為實際的值。

       http://www.microsoft.com/LCS/Samples/Filtering 是應用程序的Uri,在am文件中定義,應修改為和am文件一致,FilteringApp.am文件后會貼出。    

       -Critical $False 表示是否關鍵項,如果為True,則程序會自動啟動,並且如果該應用程序的失敗會導致整個服務崩潰。

       -Enabled $True 表示安裝后是否啟用。

       -ScriptName "C:\lync\FilteringApp\Filter.am" 腳本位置,一般ScriptOnly應用程序需要,這里修改為實際的am文件位置

      

       然后以管理員身份運行 Lync Server命令行管理程序,執行以上腳本,如下圖所示:

      

 安裝成功后,我們打開 Lync Server 2010控制面板,轉到拓撲=>服務器應用程序,刷新后就可以看到我們剛才創建的應用程序FilteringApp:
 至此,我們已經完成了ScriptOnly應用程序的安裝
 
我們繼續非ScriptOnly的應用程序Archiver的安裝。
1. 編譯應用程序,通過 命令行運行(如果是windows7,需要以管理員身份打開cmd):compile.bat Archiver
編譯完成后在Archiver目錄下生成Archiver.exe可執行文件
 
2. 將應用程序目錄Archiver復制到Lync服務器上,比如C:/lync目錄,則在C:/Lync/Archiver目錄有三個重要文件:
1)Archiver.am
View Code
<? xml version="1.0" ?>
< r:applicationManifest
 
r:appUri ="http://www.microsoft.com/LCS/Samples/Archiver"
 xmlns:r
="http://schemas.microsoft.com/lcs/2006/05" >

<!--
  - Handle all IMs, including those with strict routes
  - and those with request URIs that don't match this server's
  - domain.
  
-->
< r:requestFilter  methodNames ="MESSAGE,INVITE,ACK,BYE"
                 strictRoute
="true"
                 domainSupported
="false" />

<!--
  - Handle all responses.
  
-->
< r:responseFilter  reasonCodes ="ALL" />

< r:splScript > <![CDATA[

/*++

Script:

    Archiver.am

Abstract:

    This script dispatches incoming requests and responses to the
    managed part of the archiver sample, found in Archiver.cs.

--*/

/*
 * Dispatch all requests to the managed part of this application.
 */
if (sipRequest)
{
    Dispatch("OnRequest");
}
else
{
    Dispatch("OnResponse");
}

]]> </ r:splScript >
</ r:applicationManifest >
2)Archiver.exe 應用程序文件
 
3. 在Lync Server命令行管理程序中執行PowerShell的安裝腳本:
New-CsServerApplication -Identity  " registrar:lyncserver.corp.itime.biz/ArchiverApp " -Uri http://www.microsoft.com/LCS/Samples/Archiver -Critical  $False -Enabled  $True
 參數含義和ScriptOnly應用程序一樣,只是不需要-ScriptName參數
安裝成功后在Lync Server 2010控制面板中顯示:
 
4. 與ScriptOnly應用程序不一樣,非ScriptOnly應用程序還需要啟動。(應用程序可以控制台,窗口,服務等各種形式)此處的Archiver.exe是控制台應用程序。
 這一步有時會出現沒有權限的錯誤,那么需要檢查運行應用程序的應用是否在服務器 本地的用戶組RTC Server Applications中,如下圖所示:
 
現在,我們已經了解了MSPL服務器應用程序的部署過程。如果過程中還有問題,歡迎大家提出討論。
 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM