Mehrnoosh
Mehrnoosh

Reputation: 72

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

I'm new in the WSO2 ESB. I need your help. I get data from database by DSS and send them into a rest web service with call (in block mode) or send mediator. I split my records to individual messages in ESB by Iterate mediator and set iterate mediator properties to ture and then send date as parameters to my API. I can see in the log iterate mediator splits records to individual messages and put them in my html endpoint correctly. But I get a "read time out response" in ESB after calling my end point. If i don't use iterate mediator and I put parameters directly in the properties as test and send them to my rest API, It works fine. But when I use Iterate mediator to get parameters from DSS and send them to API, it faces with time out error. I checked log mediator to see what happened, the error is unable to send via post to my endpoint and read time out. I copied the URL for my endpoint from ESB log and tried to invoke it by SoapUI, It works fine without any time out issue.

My api is civicrm api: my Api parametrs are defined :

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

I used Call mediator for call api by blocking mode true. I sent first_name, last_name, contact_type from DSS:

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

After iterate mediator I put log mediator and can see the above value. After calling endpoint, I received this error: 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, Direction: response, MESSAGE = Executing default 'fault' sequence, ERROR_CODE = 401000, ERROR_MESSAGE = Read timed out

When I put this endpoint in SoapUI, It works. When I don't use DSS and iterate mediator and Put parametrs directly in sequence, it works.

I appreciate your help. Thanks

Upvotes: 0

Views: 795

Answers (3)

Mehrnoosh
Mehrnoosh

Reputation: 72

I've added Disable-chunking property set value to true before Send mediator.

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

The problem was solved.

Upvotes: 0

Mehrnoosh
Mehrnoosh

Reputation: 72

Yes, Thanks for your consideration. The sequence that works fine is:

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

I tried my above sequence with property Response=True instead of OUT_ONLY and it works fine as well.

my endpoint is:

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

But when I try to get first_name, last_name and contact_type from DSS and use Iterate mediator for splitting message into separate messages, I face with problem . This is my sequence:

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

Upvotes: 0

ycr
ycr

Reputation: 14574

This can hapen when a response is not sent from your backend. So you can set the following property before the send mediator to get rid of this.

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

Upvotes: 0

Related Questions