You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

自定义策略REST技术配置文件中本地化声明配置崩溃问题求助

在RESTful Provider技术配置文件中实现本地化输入声明的问题

需要在自定义策略的RESTful Provider技术配置文件(而非Self-Asserted技术配置文件)中传递带有本地化DefaultValue的输入声明,但将转换方法GetLocalizedStringsTransformation引用添加到InputClaimsTransformations后,应用程序立即崩溃。本地化输入声明必须位于RESTful Provider技术配置文件内。

自定义声明定义

<ClaimsSchema>
    <ClaimType Id="localizedResult">
        <DataType>string</DataType>
        <UserInputType>Readonly</UserInputType>
    </ClaimType>
</ClaimsSchema>

本地化配置

<Localization Enabled="true">
    <SupportedLanguages DefaultLanguage="en" MergeBehavior="ReplaceAll">
      <SupportedLanguage>en</SupportedLanguage>
      <SupportedLanguage>es</SupportedLanguage>
    </SupportedLanguages>
    <LocalizedResources Id="api.selfasserted.en">
      <LocalizedStrings>
        <LocalizedString ElementType="GetLocalizedStringsTransformationClaimType" StringId="localized_string">English Value</LocalizedString>
      </LocalizedStrings>
    </LocalizedResources>
    <LocalizedResources Id="api.selfasserted.es">
      <LocalizedStrings>
        <LocalizedString ElementType="GetLocalizedStringsTransformationClaimType" StringId="localized_string">Valor en Espanol</LocalizedString>
      </LocalizedStrings>
    </LocalizedResources>
</Localization>

声明转换配置

<ClaimsTransformations>
    <ClaimsTransformation Id="GetLocalizedStringsForCustomClaim" TransformationMethod="GetLocalizedStringsTransformation">
        <OutputClaims>
        <OutputClaim ClaimTypeReferenceId="localizedResult" TransformationClaimType="localized_string" />
        </OutputClaims>
    </ClaimsTransformation>
</ClaimsTransformations>

RESTful Provider技术配置文件

<TechnicalProfile Id="REST-Technical-Profile">
    <DisplayName>My App</DisplayName>
    <Protocol Name="Proprietary" Handler="Web.TPEngine.Providers.RestfulProvider, Web.TPEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/>
    <Metadata>
        <Item Key="IncludeClaimResolvingInClaimsHandling">true</Item>
        <Item Key="ContentDefinitionReferenceId">api.selfasserted</Item>
        <Item Key="ServiceUrl">https://my-app.test/api/endpoint</Item>
        <Item Key="SendClaimsIn">Body</Item>
        <Item Key="AuthenticationType">Bearer</Item>
    </Metadata>
    <InputClaimsTransformations>
        <InputClaimsTransformation ReferenceId="GetLocalizedStringsForCustomClaim" />
    </InputClaimsTransformations>
    <InputClaims>
        <InputClaim ClaimTypeReferenceId="myCustomClaim" DefaultValue="{Claim:localizedResult}" AlwaysUseDefaultValue="true" />
    </InputClaims>
</TechnicalProfile>

曾尝试使用CreateStringClaim方法,它能按预期生成转换后的值,但该方法无法基于语言和自定义翻译集合映射翻译。

内容的提问来源于stack exchange,提问作者Mike-S122

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.23 08:12:35