在wso2 ESB中使用Iterate介体调用序列中的restful API时,读取超时时间

时间:2016-10-06 01:04:17

标签: rest api wso2esb

我是WSO2 ESB的新成员。我需要你的帮助。我通过DSS从数据库获取数据,并通过调用(在块模式下)或发送调解器将它们发送到休息Web服务。我通过Iterate mediator将记录拆分为ESB中的单个消息,并将iterate mediator属性设置为ture,然后将日期作为参数发送到我的API。我可以在日志中看到迭代介体将记录拆分为单个消息,并将它们正确放入我的html端点。 但我得到一个"读取超时响应"在调用我的终点后在ESB中。如果我不使用迭代中介,我将参数直接放在属性中作为测试并将它们发送到我的rest API,它工作正常。但是当我使用迭代中介从DSS获取参数并将它们发送到API时,它会面临超时错误。 我检查了log mediator以查看发生了什么,错误无法通过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}

我通过阻塞模式true将call mediator用于call api。 我从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>

在迭代介体之后我放了log mediator并且可以看到上面的值。 调用端点后,我收到此错误:  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,MessageID:urn:uuid:daa47ef5-1f7a-4f2c-9372-ba17f0e282ee,方向:响应,MESSAGE =执行默认&#39;错误&#39;序列,ERROR_CODE = 401000,ERROR_MESSAGE =读取超时

当我将此端点放在SoapUI中时,它可以工作。 当我不使用DSS并按顺序迭代介体和Put参数时,它就可以工作。

感谢您的帮助。感谢

3 个答案:

答案 0 :(得分:0)

如果未从后端发送回复,则可能会出现问题。所以你可以在send mediator之前设置以下属性来摆脱它。

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

答案 1 :(得分:0)

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

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

答案 2 :(得分:0)

我在发送中介之前已将Disable-chunking属性设置值添加为true。

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

问题解决了。