0

我创建了一个代理服务,它使用 xslt 中介器转换消息,然后转换为 JSON,我现在想将 JSON 消息发布到 rest web 服务中,我如何在代理服务中直接做到这一点?这是我的代理服务:

<proxy xmlns="http://ws.apache.org/ns/synapse" name="CategoryProxy" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
   <target>
      <inSequence>
         <property name="Authorization" expression="fn:concat('Basic ', base64Encode('admin:admin'))" scope="transport" type="STRING"/>
         <send>
            <endpoint>
               <address uri="http://localhost:8068/database/library.author/301"/>
            </endpoint>
         </send>
      </inSequence>
      <outSequence>
         <xslt key="conf:/ressources/catXsl.xsl"/>
         <property name="messageType" value="application/json" scope="axis2" type="STRING"/>
         <send/>
      </outSequence>
      <faultSequence/>
   </target>
   <description></description>
</proxy>

我希望此代理发送的消息发布在其他网络资源中,我该如何在我的代理中做到这一点?

4

1 回答 1

0

看起来您正在寻找服务链,您可以通过两种方式做到这一点:

1) 使用接收序列

  <inSequence>
     <property name="Authorization" expression="fn:concat('Basic ', base64Encode('admin:admin'))" scope="transport" type="STRING"/>
     <send receive="receivingSeqForChaining">
        <endpoint>
           <address uri="http://localhost:8068/database/library.author/301"/>
        </endpoint>
     </send>
  </inSequence>

您可以在该接收序列中定义您想要的任何操作序列。来自此的输出将被分发到接收序列。如果您不想在这种情况下在 outSequence 中执行任何特定操作,您可以添加一个。

2) 使用 outSequence 触发其他服务调用

您也可以直接从 outSequence 进行 http 调用,如下所示:

<outSequence>
<send>
            <endpoint>
               <http method="get"
                     uri-template="https://www.abc.com/resource/foo"/>
            </endpoint>
         </send>
</outSequence>

希望这可以帮助。

于 2014-04-10T04:59:31.860 回答