繁体   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