Sending Content-Type application/x-www-form-urlencoded WSO2 ESB

北慕城南 提交于 2019-12-01 08:40:49

I got it this is the answer

<?xml version="1.0" encoding="UTF-8"?>
<sequence name="Mensaje" trace="enable" xmlns="http://ws.apache.org/ns/synapse">
    <property expression="json-eval($.client_secret)"
        name="client_secret" xmlns:ns="http://org.apache.synapse/xsd"/>
    <property expression="json-eval($.client_id)" name="client_id" xmlns:ns="http://org.apache.synapse/xsd"/>
    <property
        expression="fn:concat(get-property('client_id'),':',get-property('client_secret'))"
        name="Concatenados" xmlns:ns="http://org.apache.synapse/xsd"/>
    <property expression="base64Encode(get-property('Concatenados'))"
        name="Codificados" xmlns:ns="http://org.apache.synapse/xsd"/>
    <property
        expression="fn:concat('Basic ', get-property('Codificados'))"
        name="Autorizacion" xmlns:ns="http://org.apache.synapse/xsd"/>
    <property name="grant_type" value="password"/>
    <property name="username" value="admin"/>
    <property name="password" value="admin"/>
    <property name="scope" value="default"/>
    <payloadFactory media-type="xml">
        <format>
            <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
                <soapenv:Body>
                    <root xmlns="">
                        <grant_type>$1</grant_type>
                        <username>$2</username>
                        <password>$3</password>
                        <scope>$4</scope>
                    </root>
                </soapenv:Body>
            </soapenv:Envelope>
        </format>
        <args>
            <arg evaluator="xml" expression="$ctx:grant_type" xmlns:ns="http://org.apache.synapse/xsd"/>
            <arg evaluator="xml" expression="$ctx:username" xmlns:ns="http://org.apache.synapse/xsd"/>
            <arg evaluator="xml" expression="$ctx:password" xmlns:ns="http://org.apache.synapse/xsd"/>
            <arg evaluator="xml" expression="$ctx:scope" xmlns:ns="http://org.apache.synapse/xsd"/>
        </args>
    </payloadFactory>
    <header name="Content-Type" scope="transport" value="application/x-www-form-urlencoded"/>
    <header expression="get-property('Autorizacion')"
        name="Authorization" scope="transport" xmlns:ns="http://org.apache.synapse/xsd"/>
    <property name="messageType" scope="axis2" type="STRING" value="application/x-www-form-urlencoded"/>
    <property name="DISABLE_CHUNKING" scope="axis2" type="STRING" value="true"/>
    <call>
        <endpoint name="Token">
            <http method="POST" uri-template="https://localhost:9443/oauth2/token"/>
        </endpoint>
    </call>
    <respond/>
</sequence>
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!