我在文件中找到的解決方法與獲取用戶信息從https://localhost:9443/oauth2/userinfo?schema=openid
首先,變化值RemoveOAuthHeadersFromOutMessage
在OAuthConfigurations
[WSO2_AM]/repository/conf/api-manager.xml
其次,用戶聲明,即從https://localhost:9443/oauth2/userinfo?schema=openid
得到應WSO2 API管理碳服務器被配置在服務供應商。
算法:
- 複製請求主體的財產
body_of_zero_call
- 拷貝請求目標REST API方法財產
urlPostfixZero
- 設定值
?schema=openid
按要求目標REST API方法
- 呼叫https://localhost:9443/oauth2/userinfo?schema=openid獲得用戶info
- Check reponse code:if 200,then through,else return code 500 with message
{ "status": "Can't get user info"}
- 從反應體複製有趣的信息(在我的情況
user_uuid
)財產user_uuid_first_call
- 複製源請求主體從屬性
body_of_zero_call
到身體
- 複製源請求目標REST API方法從屬性
urlPostfixZero
以請求目標REST API方法
- 添加元素
userUUID
從財產user_uuid_first_call
- 呼叫目標與價值訴求的身體
- 填充元件
userUUID
身體URL與變化身體和目標REST API方法
- 迴應
中保
<?xml version="1.0" encoding="UTF-8"?>
<sequence xmlns="http://ws.apache.org/ns/synapse" name="token_to_user_uuid" trace="disable">
<!-- 1 -->
<enrich>
<source clone="true" type="body" />
<target action="child" property="body_of_zero_call" type="property" />
</enrich>
<!-- 2 -->
<property expression="$axis2:REST_URL_POSTFIX" name="urlPostfixZero" scope="default" type="STRING" />
<!-- 3 -->
<property name="REST_URL_POSTFIX" scope="axis2" type="STRING" value="?schema=openid" />
<!-- 4 -->
<call blocking="true">
<endpoint>
<http method="get" trace="disable" uri-template="https://localhost:9443/oauth2/userinfo" />
</endpoint>
</call>
<!-- 5 -->
<filter regex="200" source="get-property('axis2', 'HTTP_SC')">
<then>
<!-- 6 -->
<property expression="$body//jsonObject//user_uuid" name="user_uuid_first_call" scope="default" type="STRING" />
<!-- 7 -->
<enrich>
<source clone="true" property="body_of_zero_call" type="property" />
<target type="body" />
</enrich>
<!-- 8 -->
<property expression="get-property('urlPostfixZero')" name="REST_URL_POSTFIX" scope="axis2" type="STRING" />
<!-- 9 -->
<enrich>
<source clone="true" type="inline">
<userUUID xmlns="" />
</source>
<target action="child" xpath="$body//jsonObject" />
</enrich>
<!-- 10 -->
<enrich>
<source clone="true" property="user_uuid_first_call" type="property" />
<target xpath="$body//jsonObject//userUUID" />
</enrich>
<!-- 11 -->
<call blocking="true">
<endpoint>
<http method="post" trace="disable" uri-template="https://localhost:9444/customAuth/services/regulations" />
</endpoint>
</call>
<!-- 12 -->
<respond />
</then>
<else>
<property name="HTTP_SC" scope="axis2" type="STRING" value="500" />
<payloadFactory media-type="json">
<format>{ "status": "Can't get user info"}</format>
<args />
</payloadFactory>
<respond />
</else>
</filter>
</sequence>
非常有用的答案。你能告訴我,如何在序列中調用管理服務?也許我也可以按順序調用https:// localhost:9443/oauth2/userinfo?schema = openid? –
已經解決。 –