元数据导入

WWSAPI 包括可用于从终结点处理 WSDL 和 Policy 的 API 元素,目的是提取可用于与终结点通信的信息。 当终结点支持的通信协议尚不得而知时,通常会使用这些 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 使用率过高。

以下枚举是元数据导入的一部分:

以下函数是元数据导入的一部分:

以下句柄是元数据导入的一部分:

以下结构是元数据导入的一部分: