中繼資料匯入

WWSAPI 包含 API 元素,可用來處理端點的 WSDL 和原則,目標是擷取可用來與端點通訊的資訊。 當端點支援的通訊協定尚未知道時,通常會使用這些 API。

使用下列順序來處理中繼資料:

WsCreateMetadata    // create a metadata object

while there are metadata documents to add
{
    // retrieve the metadata document from it's location
    // (download, read from file, etc)

    // add the document to the metadata object
    WsReadMetadata

    // optionally query the metadata object for any missing documents
    WsGetMissingMetadataDocumentAddress?
}

// get the endpoints from the metadata object
WsGetMetadataEndpoints

for each endpoint
{            
    // examine the endpoint information to see if 
    // the endpoint is relevant for the particular scenario

    if the endpoint is relevant
    {
        // get the policy object from the endpoint

        // get the number of policy alternatives in the policy
        WsGetPolicyAlternativeCount

        for each policy alternative
        {
            // construct a policy constraints structure that specifies
            // what policy is acceptable and what information to extract
            // from the policy

            // see if the policy alternative matches the constraints
            WsMatchPolicyAlternative

            // if there is a match, then use it

            // if there is not a match, then it is also possible to 
            // try with a different constraint structure
        }
    }
}

// If reusing the metadata object for a different set of documents
WsResetMetadata? // reset metadata object, which removes all documents

WsFreeMetadata // free the metadata object

如需 WSDL 和WS-Policy判斷提示如何對應至 API 的詳細資訊,請參閱 中繼資料對應 主題。

安全性

下載的中繼資料只和用來下載它的位址一樣好。 應用程式應該確保信任位址。 此外,應用程式應該確保它使用安全性通訊協定來下載不允許竄改中繼資料的元資料檔案。

應用程式應該檢查中繼資料所公開之服務的位址。 根據預設,執行時間可確保服務的主機名稱符合用來下載中繼資料的原始 URL,但應用程式可能想要執行其他檢查。 應用程式可以覆寫 WS_METADATA_PROPERTY_VERIFY_HOST_NAMES 屬性來停用主機名稱驗證。 如果預設已停用所完成的主機名稱檢查,應用程式必須自行防範包含服務位址的元資料檔案,而其他方式則不信任它。

根據預設,中繼資料執行時間用來還原序列化和處理中繼資料的記憶體數量上限為 256k,而可新增的檔數目上限為 32。 這些預設值可由 WS_METADATA_PROPERTY_HEAP_REQUESTED_SIZEWS_METADATA_PROPERTY_MAX_DOCUMENTS 屬性覆寫。 這些界限的設計目的是要限制下載量,並限制配置的記憶體數量,以便累積中繼資料。 增加這些值可能會導致過多的記憶體使用量、CPU 使用量或網路頻寬耗用量。 請注意,由於二進位格式的字典字串擴充,小型訊息可能會導致較大型的還原序列化形式,因此使用二進位格式時依賴小型訊息來限制中繼資料記憶體配置並不足夠。

根據預設,原則替代專案數目上限為 32,不過可以透過 WS_POLICY_PROPERTY_MAX_ALTERNATIVES 屬性覆寫。 如果應用程式會迴圈查看尋找相符專案的每個替代專案,則可能需要搜尋所有替代專案,才能尋找相符專案。 增加替代專案數目上限可能會導致 CPU 使用率過高。

下列列舉是中繼資料匯入的一部分:

下列函式是中繼資料匯入的一部分:

下列控制碼是中繼資料匯入的一部分:

下列結構是中繼資料匯入的一部分: