获取上下文变量值 Api Azure 管理器
Get Context Variable Value Api Manager Azure
我想从一个特定变量中获取一个值。
<set-variable name="userId" value="@{string authHeader = context.Request.Headers.GetValueOrDefault("Authorization", "");string[] authHeaderParts = authHeader.Split(' ');Jwt jwt; authHeaderParts[1].TryParseJwt(out jwt);var user= jwt.Claims.GetValueOrDefault("user-id", ""); return user;}"/>
并将其传递到 SOAP 请求中。我试过了,但没用。
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns="http://tempuri.org/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Body>
<TestSoap>
<TestBody>
<user>@{context.Variables["userId"]</user>
</TestSoap>
</soap:Body>
</soap:Envelope>
如何从 userId 上下文变量中获取值?
我使用这种表示法的方法
<set-body template="liquid">
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns="http://tempuri.org/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Body>
<TestSoap>
<TestBody>
<user>{{ context.Variables.userId }}</user>
</TestBody>
</TestSoap>
</soap:Body>
</soap:Envelope>
</set-body>
对我来说是这样的:
<TestBody>
<user>{{context.Variables["userId"]}}</user>
</TestBody>
感谢大家的帮助!
我想从一个特定变量中获取一个值。
<set-variable name="userId" value="@{string authHeader = context.Request.Headers.GetValueOrDefault("Authorization", "");string[] authHeaderParts = authHeader.Split(' ');Jwt jwt; authHeaderParts[1].TryParseJwt(out jwt);var user= jwt.Claims.GetValueOrDefault("user-id", ""); return user;}"/>
并将其传递到 SOAP 请求中。我试过了,但没用。
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns="http://tempuri.org/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Body>
<TestSoap>
<TestBody>
<user>@{context.Variables["userId"]</user>
</TestSoap>
</soap:Body>
</soap:Envelope>
如何从 userId 上下文变量中获取值?
我使用这种表示法的方法
<set-body template="liquid">
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns="http://tempuri.org/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Body>
<TestSoap>
<TestBody>
<user>{{ context.Variables.userId }}</user>
</TestBody>
</TestSoap>
</soap:Body>
</soap:Envelope>
</set-body>
对我来说是这样的:
<TestBody>
<user>{{context.Variables["userId"]}}</user>
</TestBody>
感谢大家的帮助!