<?xml version="1.0" encoding="UTF-8"?>
<api context="/laboratory" name="ScienceLabAPI" xmlns="http://ws.apache.org/ns/synapse">
    <resource methods="POST" url-mapping="/users">
        <inSequence>
            <payloadFactory description="Build JSON payload from XML request" media-type="json">
                <format>{
    "name": "$1",
    "job": "$2"
}</format>
                <args>
                    <arg evaluator="xml" expression="//user/name"/>
                    <arg evaluator="xml" expression="//user/job"/>
                </args>
            </payloadFactory>
            <call description="Send request payload to endpoint">
                <endpoint key="ScienceLabEP"/>
            </call>
            <payloadFactory description="Build XML payload from JSON response" media-type="xml">
                <format>
                    <response xmlns="">
                        <status>successful</status>
                        <id>$1</id>
                        <name>$2</name>
                        <job>$3</job>
                        <createdAt>$4</createdAt>
                    </response>
                </format>
                <args>
                    <arg evaluator="json" expression="$.id"/>
                    <arg evaluator="json" expression="$.name"/>
                    <arg evaluator="json" expression="$.job"/>
                    <arg evaluator="json" expression="$.createdAt"/>
                </args>
            </payloadFactory>
            <respond description="Send response back to client"/>
        </inSequence>
        <outSequence/>
        <faultSequence/>
    </resource>
</api>
