Quantcast
Channel: Sanjeewa Malalgoda's Blog
Viewing all articles
Browse latest Browse all 220

How to convert token API response into xml format WSO2 API manager - json to soap conversion

$
0
0

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.




<apiname="_WSO2AMLoginAPI_"context="/login"xmlns="http://ws.apache.org/ns/synapse">
    <resourcemethods="POST"url-mapping="/*">
        <inSequence>
<propertyname="inSeqFORMAT"expression="$trp:Accept"/>
<propertyname="Accept"action="remove"scope="transport"/>
            <send>
                <endpoint>
                    <addressuri="https://localhost:9443/oauth2endpoints/token"/>
                </endpoint>
            </send>
        </inSequence>
        <outSequence>
<filtersource="get-property('inSeqFORMAT')"regex="application/xml">
<then>
<builder>
<messageBuildercontentType="application/json"class="org.apache.axis2.json.JSONBuilder"
formatterClass="org.apache.axis2.json.JSONMessageFormatter"/>
<messageFormattercontentType="application/xml"
class="org.apache.axis2.transport.http.ApplicationXMLFormatter"/>
</builder>
<propertyname="messageType"value="application/xml"scope="axis2"/>
<propertyname="ContentType"value="application/xml"scope="axis2"/>
<payloadFactory>
<format>
<m:rootxmlns: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>
<argexpression="//token_type"/>
<argexpression="//expires_in"/>
<argexpression="//refresh_token"/>
<argexpression="//access_token"/>
</args>
</payloadFactory>
</then>
<else>
</else>
</filter>
            <send/>
        </outSequence>
    </resource>
</api>

Viewing all articles
Browse latest Browse all 220

Trending Articles