是的,我们支持REST -REST服务,这意味着它在协议切换下进行分类,使用WSO2 ESB,它具有REST API,使您可以处理传入的REST或任何其他格式并进行调解并将它们传递到后端(它不会哪个协议是关键的)
如果您需要访问可能必须使用的表格数据,以下代理允许您将收到的REST消息传输到后端REST服务
<messageFormatter contentType ="application/x-www-form-urlencoded"class ="org.apache.axis2.transport.http.XFormURLEncodedFormatter"/>
<messageBuilder contentType ="application/x-www-form-urlencoded"class ="org.apache.synapse.commons.builders.XFormURLEncodedBuilder"/>
它允许您提取包含REST提交详细信息并根据您的喜好进行任何调解
REST TO REST VIA REST API
<api name="studentSecureAPI" context="/SecureStudentRequest">
<resource methods="POST" uri-template="/student/{name}">
<inSequence>
<property name="REST_URI" expression="fn:substring($axis2:REST_URL_POSTFIX,16,fn:string-length($axis2:REST_URL_POSTFIX))"/>
<property name="AGE" expression="//xformValues//age"/>
<property name="STUDENT" expression="get-property('uri.var.name')"/>
<property name="DISABLE_CHUNKING" value="true" scope="axis2" type="STRING"/>
<property name="HTTP_METHOD" value="POST" scope="axis2" type="STRING"/>
<property name="ContentType" value="application/x-www-form-urlencoded" scope="axis2" type="STRING"/>
<property name="REST_URL_POSTFIX" scope="axis2" action="remove"/>
<property name="REST_URL_POSTFIX" expression="$ctx:REST_URI" scope="axis2"/>
<payloadFactory>
<format>
<POST>
<age>$1</age>
</POST>
</format>
<args>
<arg expression="$ctx:AGE"/>
</args>
</payloadFactory>
<send>
<endpoint>
<address uri="http://localhost:9764/as/services/RestService"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<send/>
</outSequence>
</resource>
Run Code Online (Sandbox Code Playgroud)
REST TO REST VIA SIMPLE PROXY :
<proxy name="StudentRequestProxy" transports="https http" startOnLoad="true" trace="disable">
<target>
<inSequence>
<property name="DISABLE_CHUNKING" value="true" scope="axis2" type="STRING"/>
<property name="ContentType" value="text/xml" scope="axis2" type="STRING"/>
<property xmlns:ns3="http://org.apache.synapse/xsd" name="Lang" expression="get-property('transport', 'Accept')" scope="default" type="STRING"/>
<log level="custom">
<property name="HTTP_METHOD IS###########" expression="$axis2:HTTP_METHOD"/>
</log>
<switch source="$axis2:HTTP_METHOD">
<case regex="GET">
<property name="HTTP_METHOD" value="GET" scope="axis2" type="STRING"/>
</case>
<case regex="POST">
<property name="HTTP_METHOD" value="POST" scope="axis2" type="STRING"/>
</case>
<default/>
</switch>
<send>
<endpoint>
<address uri="http://localhost:9764/as/services/RestService"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<send/>
</outSequence>
</target>
</proxy>
Run Code Online (Sandbox Code Playgroud)