共用方式為


元數據匯入

WWSAPI 包含 API 元素,可用來處理端點的 WSDL 和 Policy,目標是擷取可用來與端點通訊的資訊。 當端點所支持的通訊協定尚未知道時,通常會使用這些 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使用率過高。

下列列舉是元數據匯入的一部分:

下列函式是元數據匯入的一部分:

下列句柄是元數據匯入的一部分:

下列結構是元數據匯入的一部分: