簡體   English   中英

如何在代理中使用wso2 esb連接器

[英]how to use wso2 esb connector in proxy

我從git下載esb連接器,並按照步驟部署foo-connector。 這些操作都可以。

在嘗試創建一個代理嘗試使用此連接器之后,並由提琴手使用url“ http://t00012-laptop:8010/services/foo ”進行調用。 ESB始終給出響應202。

esb代理配置如下:

<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="foo"
       transports="https,http"
       statistics="disable"
       trace="disable"
       startOnLoad="true">
   <target>
      <inSequence>         
        <property name="FORCE_SC_ACCEPTED" value="true" scope="axis2" type="BOOLEAN"/>
         <foo.foo-operation>         
         </foo.foo-operation>        
      </inSequence>
      <outSequence>
         <log/>
         <send/>
      </outSequence>
   </target>
   <description/>
</proxy>

看看foo連接器源代碼:

  • foo-operation是一個模板,該模板僅記錄消息有效負載和名為“ generate_param”的參數的值,然后調用類org.wso2.carbon.connector.foo

  • 此類在std輸出中輸出Hello World,其值為“ generated_pa​​ram”

如果您像這樣更改代理定義:

<proxy xmlns="http://ws.apache.org/ns/synapse" name="foo" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
    <target>
        <inSequence>
            <property name="FORCE_SC_ACCEPTED" value="true" scope="axis2" type="STRING"/>
            <foo.foo-operation>
                <generated_param>ROJ</generated_param>
            </foo.foo-operation>
        </inSequence>
    </target>
    <description/>
</proxy>

呼叫http://t00012-laptop:8010/services/foo :您將收到一個空的響應,帶有http狀態代碼202,並將在ESB的std輸出中看到:

[2014-09-19 08:20:44,640]  INFO - LogMediator To: /services/TestFOO, MessageID:
urn:uuid:874f494e-86fa-49b5-b0b5-2b5f781eca43, Direction: request, template_para
m = ROJ, Envelope: <?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns
:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body></soapenv:Bod
y></soapenv:Envelope>
Hello WORLD foo !!! : paramter :ROJ

就這樣...

如果要將端點的響應返回給調用方,只需在inSequence內添加響應標簽,如下所示。

 <?xml version="1.0" encoding="UTF-8"?>
    <proxy xmlns="http://ws.apache.org/ns/synapse"
           name="foo"
           transports="https,http"
           statistics="disable"
           trace="disable"
           startOnLoad="true">
       <target>
          <inSequence>         
            <property name="FORCE_SC_ACCEPTED" value="true" scope="axis2" type="BOOLEAN"/>
             <foo.foo-operation>         
             </foo.foo-operation> 
             <respond/>       
          </inSequence>
          <outSequence>
             <log/>
             <send/>
          </outSequence>
       </target>
       <description/>
    </proxy>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM