繁体   English   中英

WSO2 ESB调用具有文本/纯内容的REST API

[英]WSO2 ESB Call a REST API with text/plain content

我需要使用正文中的纯文本来调用REST API。

CURL命令

curl -X POST http://mydomain.test.corp/token -H "Content-Type: text/plain" -d "grant_type=password&username=testUName&password=123123"

给我想要的输出。 如何将其构建为代理服务。 我在考虑有效负载介体,但它仅接受媒体类型xml / json。

由于我认为与号,我grant_type=password&username=testUName&password=123123在代理服务xml中保存grant_type=password&username=testUName&password=123123

很感谢任何形式的帮助。

谢谢。

使用有效负载中介程序,并构建包含您的纯文本作为该节点的值的SOAP消息: <text xmlns="http://ws.apache.org/commons/ns/payload">

&amp;替换& 或使用CDATA

指定消息类型(以便使用适当的messageFormatter):

<property name="messageType" value="text/plain; charset=windows-1252" scope="axis2"/>

只需发送此消息

完整样本:

<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse" name="TestSOF" transports="http" startOnLoad="true" trace="disable">
   <description/>
   <target>
      <inSequence>
         <payloadFactory media-type="xml">
            <format>
               <text xmlns="http://ws.apache.org/commons/ns/payload"><![CDATA[grant_type=password&username=testUName&password=123123]]></text>
            </format>
            <args/>
         </payloadFactory>
         <property name="messageType" value="text/plain" scope="axis2" type="STRING"/>
         <property name="HTTP_METHOD" value="POST" scope="axis2" type="STRING"/>
         <send>
            <endpoint>
               <address uri="http://localhost:8888/MockJSP.jsp"/>
            </endpoint>
         </send>
      </inSequence>
      <outSequence>
         <send/>
      </outSequence>
   </target>
</proxy>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM