Here in this post i have described how to convert token/login API response into xml format WSO2 API manager. This is similar to json to soap conversion in WSO2 ESB. Here is the updated token API. Please copy this and replace with current token api synapse configuration.
<api name="_WSO2AMLoginAPI_" context="/login" xmlns="http://ws.apache.org/ns/synapse"> <resource methods="POST" url-mapping="/*"> <inSequence> <property name="inSeqFORMAT" expression="$trp:Accept"/> <property name="Accept" action="remove" scope="transport"/> <send> <endpoint> <address uri="https://localhost:9443/oauth2endpoints/token"/> </endpoint> </send> </inSequence> <outSequence> <filter source="get-property('inSeqFORMAT')" regex="application/xml"> <then> <builder> <messageBuilder contentType="application/json" class="org.apache.axis2.json.JSONBuilder" formatterClass="org.apache.axis2.json.JSONMessageFormatter"/> <messageFormatter contentType="application/xml" class="org.apache.axis2.transport.http.ApplicationXMLFormatter"/> </builder> <property name="messageType" value="application/xml" scope="axis2"/> <property name="ContentType" value="application/xml" scope="axis2"/> <payloadFactory> <format> <m:root xmlns:m="http://services.samples"> <token_type>$1</token_type> <expires_in>$2</expires_in> <refresh_token>$3</refresh_token> <access_token>$4</access_token> </m:root> </format> <args> <arg expression="//token_type"/> <arg expression="//expires_in"/> <arg expression="//refresh_token"/> <arg expression="//access_token"/> </args> </payloadFactory> </then> <else> </else> </filter> <send/> </outSequence> </resource> </api>
No comments:
Post a Comment