| Author | Message | 
		
		  | mr2kn | 
			  
				|  Posted: Thu Apr 07, 2016 7:57 am    Post subject: sending multiple times request to same endpoint |   |  | 
		
		  | Apprentice
 
 
 Joined: 26 Jan 2016Posts: 46
 
 
 | 
			  
				| Hi, 
 Thank you for looking this message/request which im facing it, could you please help on this issue in IIB9 and if possible any code/sample I can get
 
 I will get soap request in this format
 
 <request>
 <Item> <article>1</article><part>001</part> </item>
 <Item> <article>2</article><part>002</part> </item>
 </request>
 
 I need to endpoint through http request node by one by one
 1st <Item> after getting the response store it after that send
 2nd <Item> after getting the response store it like continues and finally I need to get the response like this
 
 <response>
 <itemresponse> ..... </itemresponse>
 <itemresponse> ..... </itemresponse>
 </response>
 
 im trying to build like this
 
 soapinput --> compute ---> Route to label
 label ---> httprequest ---> compute1 --- soapreply
 
 in compute im taking the count how many <item> is there and doing a while loop to construct the 1st <Item> and sending the request aafter getting the response I stored it, after that it compute1 returned back to compute to select next one but im not able to create the 2nd <Item> body and also in compute1 im loosing the 1st <Itemresponse> if any error comes from 2nd <Item>
 all request and response travel with JSON format
 
 Please help on this and appreciate,
 thank you
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | timber | 
			  
				|  Posted: Thu Apr 07, 2016 8:36 am    Post subject: |   |  | 
		
		  |  Grand Master
 
 
 Joined: 25 Aug 2015Posts: 1292
 
 
 | 
			  
				| 
  Counted loops in ESQL are slow and cumbersome. A FOR loop is usually the best approach. 
	| Quote: |  
	| in compute im taking the count how many <item> is there |  
 
  er...did you read this before you submitted it? There's a Preview button. 
	| Quote: |  
	| after that it compute1 returned back to compute to select next one |  
 
  Why not? We cannot help until you explain what you did, and what happened. 
	| Quote: |  
	| but im not able to create the 2nd <Item> body |  |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | mr2kn | 
			  
				|  Posted: Thu Apr 07, 2016 8:49 am    Post subject: |   |  | 
		
		  | Apprentice
 
 
 Joined: 26 Jan 2016Posts: 46
 
 
 | 
			  
				| Thank you for reading my concern, 
 in the compute node I did like this
 CREATE LASTCHILD OF Environment.Variables DOMAIN('JSON') IDENTITY(JSON.Array);
 DECLARE J INTEGER;
 DECLARE S INTEGER 1;
 
 SET J = CARDINALITY(envRef.createOrUpdateVendorRequests.*[]);
 WHILE I <= J DO
 SET OutputLocalEnvironment.Destination.RouterList.DestinationData.labelName = 'VendorRequest';
 
 FOR S1 AS envRef.createOrUpdateVendorRequests[] DO
 
 CREATE LASTCHILD OF Environment.Variables DOMAIN('JSON');
 SET Environment.Variables.JSON.Data.obj[S].entity = envRef.createOrUpdateVendorRequests.createOrUpdateVendorRequest.obj[S].entity;
 SET Environment.Variables.I = I;
 PROPAGATE DELETE NONE;
 SET S = S + 1;
 SET I = I + 1;
 END FOR;
 END WHILE;
 RETURN FALSE;
 
 1st <Item> is successfully getting response and store in the env variables from compute1 node
 when returning for second time to get the 2nd <Item> then no values and getting error as missing fields from the response
 
 hope this helps to find out my wrong/right coding 1st time im doing it like this
 thank you
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | timber | 
			  
				|  Posted: Thu Apr 07, 2016 11:06 am    Post subject: |   |  | 
		
		  |  Grand Master
 
 
 Joined: 25 Aug 2015Posts: 1292
 
 
 | 
			  
				| When posting code to this forum, please use the Code button to format the code properly. Like this: 
  There are several things wrong with your code. 
	| Code: |  
	| CREATE LASTCHILD OF Environment.Variables DOMAIN('JSON') IDENTITY(JSON.Array); DECLARE J INTEGER;
 DECLARE S INTEGER 1;
 
 SET J = CARDINALITY(envRef.createOrUpdateVendorRequests.*[]);
 WHILE I <= J DO
 SET OutputLocalEnvironment.Destination.RouterList.DestinationData.labelName = 'VendorRequest';
 
 FOR S1 AS envRef.createOrUpdateVendorRequests[] DO
 
 CREATE LASTCHILD OF Environment.Variables DOMAIN('JSON');
 SET Environment.Variables.JSON.Data.obj[S].entity = envRef.createOrUpdateVendorRequests.createOrUpdateVendorRequest.obj[S].entity;
 SET Environment.Variables.I = I;
 PROPAGATE DELETE NONE;
 SET S = S + 1;
 SET I = I + 1;
 END FOR;
 END WHILE;
 RETURN FALSE;
 |  1. It is not indented properly. That's very bad practice, and usually leads to defects.
 2. Your code uses indexes and a counter for the outer loop, but a FOR statement for the inner loop. Why?
 3. Your code is creating the JSON parent node once for every iteration of the inner loop. Is that what you intended?
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | mr2kn | 
			  
				|  Posted: Thu Apr 07, 2016 11:41 am    Post subject: |   |  | 
		
		  | Apprentice
 
 
 Joined: 26 Jan 2016Posts: 46
 
 
 | 
			  
				| im trying to index it so that next <Item> records take it, but its not and im in wrong way yes, JSON is creating parent node once for every iteration of the inner loop like that, because every request needs to go as a new request header,body
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | timber | 
			  
				|  Posted: Thu Apr 07, 2016 1:26 pm    Post subject: |   |  | 
		
		  |  Grand Master
 
 
 Joined: 25 Aug 2015Posts: 1292
 
 
 | 
			  
				| 
  You can do everything that you need to do using WHILE or FOR statements and CREATE LASTCHILD... 
	| Quote: |  
	| im trying to index it so that next <Item> records take it |  
 I do not understand what you meant when you said:
 
  No values get automatically 'returned' after the PROPAGATE statement. What 'error' are you getting? 
	| Quote: |  
	| when returning for second time to get the 2nd <Item> then no values and getting error as missing fields from the response |  
 Remember that we cannot see your message flow. We cannot read your screen. We don't know what design decisions you have taken. You need to tell us these things.
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | mr2kn | 
			  
				|  Posted: Thu Apr 07, 2016 5:20 pm    Post subject: |   |  | 
		
		  | Apprentice
 
 
 Joined: 26 Jan 2016Posts: 46
 
 
 | 
			  
				| thank you for the patience 
 2nd<Item> means
 
 <request>
 1st     <Item> <article>1</article><part>001</part> </item>
 2nd    <Item> <article>2</article><part>002</part> </item>
 </request>
 
 this is the message flow,
 soapinput --> compute ---> Route to label
 label ---> httprequest ---> compute1 --- soapreply
 
 when I process 1st<Item> it will process it and success response received in compute1 node after that it will returned to compute node again and to get the 2nd <Item> structure that time there is no structure in the body  and received an error missing data in the object
 
 the request im processing through environment.variables
 
 And not sure this is right approach or not
 
 and I want to make like in WESB fan-out primitive where in the properties
 we are mentioning like by selecting the option
 
 -for each element xpath expression <body path>
 -Check for asynchronous response after 1 message have been fired
 
 hope tried to explained
 
 thank you
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | Vitor | 
			  
				|  Posted: Thu Apr 07, 2016 5:35 pm    Post subject: |   |  | 
		
		  |  Grand High Poobah
 
 
 Joined: 11 Nov 2005Posts: 26093
 Location: Texas, USA
 
 | 
			  
				| 
   
	| mr2kn wrote: |  
	| when I process 1st<Item> it will process it and success response received in compute1 node after that it will returned to compute node again and to get the 2nd <Item> structure that time there is no structure in the body  and received an error missing data in the object |  
 What do you mean by "success response received in compute1 node"? Something propagated does not return a response.
 
 
 
   
	| mr2kn wrote: |  
	| and I want to make like in WESB fan-out primitive where in the properties |  
 Then why not use the IIB fan-out primitives (the Aggregation nodes) rather than rolling your own in this unlikely way?
 _________________
 Honesty is the best policy.
 Insanity is the best defence.
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | mqjeff | 
			  
				|  Posted: Fri Apr 08, 2016 5:01 am    Post subject: |   |  | 
		
		  | Grand Master
 
 
 Joined: 25 Jun 2008Posts: 17447
 
 
 | 
			  
				| 
  Except for an, umm, Exception... 
	| Vitor wrote: |  
	| Something propagated does not return a response. |  
  _________________
 chmod  -R ugo-wx /
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | timber | 
			  
				|  Posted: Fri Apr 08, 2016 6:43 am    Post subject: |   |  | 
		
		  |  Grand Master
 
 
 Joined: 25 Aug 2015Posts: 1292
 
 
 | 
			  
				| I think I understand now. This inner loop... 
  ...is executing successfully the first time. But on the second iteration of the loop ( after the PROPAGATE ) you are finding that envRef.createOrUpdateVendorRequests.createOrUpdateVendorRequest.obj[2].entity is empty. 
	| Code: |  
	| FOR S1 AS envRef.createOrUpdateVendorRequests[] DO 
 CREATE LASTCHILD OF Environment.Variables DOMAIN('JSON');
 SET Environment.Variables.JSON.Data.obj[S].entity = envRef.createOrUpdateVendorRequests.createOrUpdateVendorRequest.obj[S].entity;
 SET Environment.Variables.I = I;
 PROPAGATE DELETE NONE;
 SET S = S + 1;
 SET I = I + 1;
 END FOR;
 |  
 Is that correct?
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | mr2kn | 
			  
				|  Posted: Fri Apr 08, 2016 7:13 am    Post subject: |   |  | 
		
		  | Apprentice
 
 
 Joined: 26 Jan 2016Posts: 46
 
 
 | 
			  
				| Thank you Timber, yes, correct for the second iteration all are empty
 
 Hi Vitor,
 success response received in compute1 node means after httprequest node giving me the response to compute1 node, where I need to store one by one response
 
 im not sure to use the aggregate node I can use it, because MQ's also need to introduce here to use it if im aware, and difficult for me to introduce in our application
 
 thank you for looking into this
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | mqjeff | 
			  
				|  Posted: Fri Apr 08, 2016 7:17 am    Post subject: |   |  | 
		
		  | Grand Master
 
 
 Joined: 25 Jun 2008Posts: 17447
 
 
 | 
			  
				| Study the aggregation samples. 
 Read Vitor's comment about propagate not returning anything.  Think about it, several times.
 
 Think about where you can get the responses you are trying to aggregate.
 
 Study the aggregation samples.
 _________________
 chmod  -R ugo-wx /
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | mr2kn | 
			  
				|  Posted: Fri Apr 08, 2016 9:32 am    Post subject: |   |  | 
		
		  | Apprentice
 
 
 Joined: 26 Jan 2016Posts: 46
 
 
 | 
			  
				| now im able to send the request one by one from compute node to httprequest node and getting the Item response in compute1 node 
 and here I need to know how I can store it one by one
 <response>
 <itemresponse> ..... </itemresponse>
 <itemresponse> ..... </itemresponse>
 </response>
 
 please provide any help
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | Vitor | 
			  
				|  Posted: Sat Apr 09, 2016 3:54 am    Post subject: |   |  | 
		
		  |  Grand High Poobah
 
 
 Joined: 11 Nov 2005Posts: 26093
 Location: Texas, USA
 
 | 
			  
				| 
   
	| mr2kn wrote: |  
	| im not sure to use the aggregate node I can use it, because MQ's also need to introduce here to use it if im aware, and difficult for me to introduce in our application |  
 You're not trying to introduce it into your application.
 
 You're trying to use it within your flow because the aggregation nodes use it. It's one of the reasons your IIBv9 broker is associated with a queue manager.
 
 As my most worthy associate advises, look at the samples. There's no reason why you can't use aggregation to make multiple web service calls and produce a single response. Indeed, it's one of the typical use cases for such a pattern.
 _________________
 Honesty is the best policy.
 Insanity is the best defence.
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  | mr2kn | 
			  
				|  Posted: Tue Apr 12, 2016 7:21 am    Post subject: |   |  | 
		
		  | Apprentice
 
 
 Joined: 26 Jan 2016Posts: 46
 
 
 | 
			  
				| Hi, Sorry for late response,
 I tried to use and working fine, but my architect told try to use without aggregate and reason behind I don't know, that is the reason im tying it without aggregate,
 will update in the post if anything comes positive results
 |  | 
		
		  | Back to top |  | 
		
		  |  | 
		
		  |  |