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

时间:2014-09-18 14:18:59

标签: wso2 wso2esb

我从git下载esb连接器,然后按照步骤部署foo-connector。这些操作都可以。

在我尝试创建代理以尝试此连接器之后,由fiddler使用url调用 " http://t00012-laptop:8010/services/foo&#34 ;. 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>

2 个答案:

答案 0 :(得分:2)

查看foo连接器源代码:

  • foo-operation是一个只记录消息有效负载+的模板 名为“generated_pa​​ram”的参数值,然后调用类org.wso2.carbon.connector.foo

  • 本课程在标准版中打印Hello WORLD 输出值为“generated_pa​​ram”

如果您更改代理def,请执行以下操作:

<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

这就是......

答案 1 :(得分:0)

如果要将端点的响应返回给调用者,只需在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>