在 wso2 ESB 中使用 Iterate mediator 在序列中调用 restful API 时读取超时

Get read time out when Call restful API in the sequence with Iterate mediator in wso2 ESB

我是 WSO2 ESB 的新手。我需要你的帮助。我通过 DSS 从数据库中获取数据,并通过调用(以块模式)或发送调解器将它们发送到休息 Web 服务。我通过 Iterate mediator 将我的记录拆分为 ESB 中的各个消息,并将 iterate mediator 属性设置为 ture,然后将日期作为参数发送到我的 API。我可以在日志中看到迭代调解器将记录拆分为单独的消息并将它们正确地放入我的 html 端点。 但是在调用我的终点后,我在 ESB 中得到了一个 "read time out response"。如果我不使用迭代调解器并且我将参数直接放在属性中作为测试并将它们发送到我的其余部分 API,它工作正常。但是当我使用 Iterate mediator 从 DSS 获取参数并将它们发送到 API 时,它面临超时错误。 我检查了日志调解器以查看发生了什么,错误无法通过 post 发送到我的端点并读取超时。我从 ESB 日志中为我的端点复制了 URL,并尝试通过 SoapUI 调用它,它工作正常,没有任何超时问题。

我的 api 是 civicrm api:我的 Api 参数已定义:

contact_type={uri.var.contact_type}
first_name={uri.var.first_name}
last_name={uri.var.last_name}

我使用调用调解器进行调用 api,阻塞模式为 true。 我从 DSS 发送了 first_name、last_name、contact_type:

<Submissions>
 <Submission>
  <contact_type>Individual</contact_type>
  <first_name>Testname</first_name>
  <last_name>TestFamily</last_name>
</Submission>
</Submissions>

迭代调解器后,我放入了日志调解器,可以看到上面的值。 调用端点后,我收到此错误: http://localhost/CIVICRM/sites/all/modules/civicrm/extern/rest.php?entity=Contact&action=create&key=1111&user=test&pass=passsss&api_key=1111111111&version=3&contact_type=Individual&first_name=Testname&last_name=TestFamily,消息 ID:urn:uuid:daa47ef5-1f7a-4f2c-9372-ba17f0e282ee,方向:响应,消息 = 执行默认“故障”序列,ERROR_CODE = 401000,ERROR_MESSAGE = 读取超时

当我将此端点放入 SoapUI 时,它起作用了。 当我不使用 DSS 并直接按顺序迭代 mediator 和 Put parametrs 时,它起作用了。

感谢您的帮助。谢谢

当您的后端未发送响应时,可能会发生这种情况。所以你可以在发送中介之前设置以下属性来摆脱这个。

<property name="OUT_ONLY" value="true"/>

是的,感谢您的考虑。工作正常的顺序是:

<sequence xmlns="http://ws.apache.org/ns/synapse"
          name="importCiviCRM"
          trace="disable">
   <property name="uri.var.type"
             value="Individual"
             scope="default"
             type="STRING"/>
   <property name="uri.var.first"
             value="aaaaaa"
             scope="default"
             type="STRING"/>
   <property name="uri.var.last"
             value="bbbbbbb"
             scope="default"
             type="STRING"/>
   <property name="FORCE_HTTP_CONTENT_LENGTH"
             value="true"
             scope="axis2"
             type="STRING"/>
   <property name="COPY_CONTENT_LENGTH_FROM_INCOMING"
             value="true"
             scope="axis2"
             type="STRING"/>
   <property name="HTTP_METHOD" value="POST" scope="axis2" type="STRING"/>
   <property name="messageType"
             value="application/xml"
             scope="axis2"
             type="STRING"/>
   <header name="To" scope="default" action="remove"/>
   <property name="OUT_ONLY" value="true" scope="default" type="STRING"/>
   <property name="NO_ENTITY_BODY" scope="axis2" action="remove"/>

   <send buildmessage="true">
      <endpoint key="CiviImport"/>
   </send>
</sequence>

我用 属性 Response=True 而不是 OUT_ONLY 尝试了上面的序列,它也工作正常。

我的终点是:

<endpoint xmlns="http://ws.apache.org/ns/synapse" name="CiviImport">
   <http uri-template="http://localhost/CIVICRM%20WAREHOUSE/sites/all/modules/civicrm/extern/rest.php?entity=Contact&amp;action=create&amp;key=111111&amp;user=Testuser&amp;pass=Testpass&amp;api_key=111111111&amp;version=3&amp;contact_type={uri.var.type}&amp;first_name={uri.var.first}&amp;last_name={uri.var.last}"/>
</endpoint>

但是当我尝试从 DSS 获取 first_name、last_name 和 contact_type 并使用 Iterate mediator 将消息拆分为单独的消息时,我遇到了问题。这是我的顺序:

<?xml version="1.0" encoding="UTF-8"?>
<sequence xmlns="http://ws.apache.org/ns/synapse" name="CiviCrmAPI">
   <iterate xmlns:dss="http://ws.wso2.org/dataservice"
            xmlns:ns="http://org.apache.synapse/xsd"
            continueParent="true"
            id="IterateRequestSink"
            expression="//dss:Submission"
            sequential="true">
      <target>
         <sequence>
            <property name="uri.var.type"
                      expression="//dss:contact_type/text()"
                      scope="default"
                      type="STRING"/>
            <property name="uri.var.first"
                      expression="//dss:first_name/text()"
                      scope="default"
                      type="STRING"/>
            <property name="uri.var.last"
                      expression="//dss:last_name/text()"
                      scope="default"
                      type="STRING"/>
            <log>
               <property name="uri.var.type" expression="get-property('uri.var.type')"/>
               <property name="uri.var.first" expression="get-property('uri.var.first')"/>
               <property name="uri.var.last" expression="get-property('uri.var.last')"/>
            </log>
            <property name="FORCE_HTTP_CONTENT_LENGTH"
                      value="true"
                      scope="axis2"
                      type="STRING"/>
            <property name="COPY_CONTENT_LENGTH_FROM_INCOMING"
                      value="true"
                      scope="axis2"
                      type="STRING"/>
            <property name="HTTP_METHOD" value="POST" scope="axis2" type="STRING"/>
            <property name="messageType"
                      value="application/xml"
                      scope="axis2"
                      type="STRING"/>
            <header name="To" scope="default" action="remove"/>
            <property name="OUT_ONLY" value="true" scope="default" type="STRING"/>
            <property name="NO_ENTITY_BODY" scope="axis2" action="remove"/>
            <send buildmessage="true">
               <endpoint key="CiviImport"/>
            </send>
         </sequence>
      </target>
   </iterate>
</sequence>

我添加了 Disable-chunking 属性 在 Send mediator 之前将值设置为 true。

 <property name="DISABLE_CHUNKING" value="true" scope="axis2"/>

问题已解决。