【问题标题】:Why WSO2 Send Mediator doesn't wait for response?为什么 WSO2 Send Mediator 不等待响应?
【发布时间】:2023-04-10 05:17:01
【问题描述】:

我有一个 WSO2 ESB-4.6.0 代理,它调用另一个调用 Web 服务的代理。

Proxy1 --> Proxy2 --> Endpoint

如果我直接通过soapUI调用第二个代理,响应正确返回并打印,但如果我调用第一个代理,则返回一个空白正文。

在 ESB 日志中,Proxy1 的 outSequence 打印在 Proxy2 的 outSequence 之前。 似乎 Proxy1 的 inSequence 中的发送中介正在对 Proxy2 进行异步调用。
我试图用 Callout 调解器替换 Send 调解器,但结果是一样的。
关注this 教程,但它也不起作用。

如何将 Proxy2 的响应转发给调用者?
请帮忙。想死我了!

编辑

问题解决了!我使用了错误的端口来为 Callout 中介器指定 serviceURL 参数。

编辑

当前代理配置:

代理 1(调用代理 2 - ManageWorkforce):

<proxy xmlns="http://ws.apache.org/ns/synapse" name="GetAppointmentSchedulePortalReqCS" transports="http https" startOnLoad="true" trace="disable">
    <target>
        <inSequence>
            <xslt key="conf:ManageWorkforce/xslt/GetAppointmentSchedulePortalReqCS_Request.xsl"/>
            <header name="Action" value="getAppointment"/>
            <send>
                <endpoint>
                    <address uri="https://localhost:9443/services/ManageWorkforce"/>
                </endpoint>
            </send>
        </inSequence>
        <outSequence>
            <xslt key="conf:ManageWorkforce/xslt/GetAppointmentSchedulePortalReqCS_Response.xsl"/>
            <send/>
        </outSequence>
        <faultSequence/>
    </target>
    <publishWSDL key="conf:ManageWorkforce/GetAppointmentSchedulePortalReqCS.wsdl" />
</proxy>

代理 2(调用 Proxy3 -GetAppointmentPeopleProvCS):

<proxy xmlns="http://ws.apache.org/ns/synapse" name="ManageWorkforce" transports="https http" startOnLoad="true" trace="disable">
    <target>
        <inSequence>
            <switch source="get-property('Action')">
                <case regex="getAppointment">
                    <callout serviceURL="https://localhost:8243/services/GetAppointmentPeopleProvCS" action="getAppointment">
                        <source xmlns:s12="http://www.w3.org/2003/05/soap-envelope" xmlns:s11="http://schemas.xmlsoap.org/soap/envelope/" xpath="s11:Body/child::*[fn:position()=1] | s12:Body/child::*[fn:position()=1]"/>
                        <target xmlns:s12="http://www.w3.org/2003/05/soap-envelope" xmlns:s11="http://schemas.xmlsoap.org/soap/envelope/" xpath="s11:Body/child::*[fn:position()=1] | s12:Body/child::*[fn:position()=1]"/>
                    </callout>
                </case>
                <!-- another cases -->
                <default/>
            </switch>
            <property name="RESPONSE" value="true" scope="default" type="STRING"/>
            <header name="To" action="remove"/>
            <send/>
        </inSequence>
        <outSequence>
            <drop/>
        </outSequence>
        <faultSequence/>
    </target>
    <publishWSDL key="conf:ManageWorkforce/ManageWorkforce.wsdl"/>
    </publishWSDL>
</proxy>

代理3(调用服务-GetAppointment):

<proxy xmlns="http://ws.apache.org/ns/synapse" name="GetAppointmentPeopleProvCS" transports="http https" serviceGroup="" startOnLoad="true" trace="disable">
    <target>
        <endpoint key="GetAppointment"/>
        <inSequence>
            <xslt key="conf:ManageWorkforce/xslt/GetAppointmentPeopleProvCS_Request.xsl"/>
        </inSequence>
        <outSequence>
            <xslt key="conf:ManageWorkforce/xslt/GetAppointmentPeopleProvCS_Response.xsl"/>
            <send/>
        </outSequence>
        <faultSequence/>
    </target>
</proxy>

最终端点(服务):

<endpoint xmlns="http://ws.apache.org/ns/synapse" name="GetAppointment">
    <address uri="http://10.13.6.75:9764/services/GetAppointment" />
</endpoint>

【问题讨论】:

    标签: wso2 soa wso2esb


    【解决方案1】:

    有两个中介可以调用 Web 服务。这些是Callout MediatorCall Mediator。 Callout 调解器执行阻塞调用,调用调解器执行非阻塞调用。

    因此,如果您考虑性能,您应该使用 Call mediator。它在 ESB 4.8.0 中可用。

    在 wiki 文档中有两个 samples

    还有一个sample 来自 Dushan 的博客的 Call Mediator。这有更复杂的中介,但你可以试试。

    这只是一个快速的答案。

    我希望这会有所帮助。

    谢谢!

    【讨论】:

    • 但是调用中介的等待在迭代中介中不起作用。如何正确处理?
    【解决方案2】:

    即使您使用发送中介,Proxy1 也会等待来自 Proxy2 的响应。 Proxy1 的 outSequence 不应在 Proxy2 的 outSequence 执行之前执行。

    切换到 Callout Mediator 不是理想的解决方案。 我认为代理配置应该有问题。

    如果您可以在此处发布代理配置,我们或许可以帮助您解决此问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-11-12
      • 2020-01-23
      • 2022-01-21
      相关资源
      最近更新 更多