| Author | 
		  Message
		 | 
		
		  | akil | 
		  
		    
			  
				 Posted: Wed May 28, 2014 10:39 am    Post subject: Implementing a REST Interface : IIB9 | 
				     | 
			   
			 
		   | 
		
		
		    Partisan
 
 Joined: 27 May 2014 Posts: 338 Location: Mumbai 
  | 
		  
		    
			  
				Hi
 
 
Is there a recommended or a built in way to implement a REST interface in IIB9 ? The intent is to expose conventional URI's such as 
 
 
GET /classes
 
GET /students
 
GET /class/:id
 
GET /student/:id
 
PUT /class/new
 
 
and so on.. for the class and student entity.
 
 
The responses are easy to create with a mapping node (and a db:select) or a MQ exchange with the host system. I am wondering about how to process the requests ( parse URL's , calling appropriate mapping nodes or MQ sub flows ) .. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | fjb_saper | 
		  
		    
			  
				 Posted: Wed May 28, 2014 12:43 pm    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Grand High Poobah
 
 Joined: 18 Nov 2003 Posts: 20768 Location: LI,NY 
  | 
		  
		    
			  
				Send the url with a query string on a post
 
Work off the xml...   _________________ MQ & Broker admin | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | akil | 
		  
		    
			  
				 Posted: Sat Jul 19, 2014 5:32 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Partisan
 
 Joined: 27 May 2014 Posts: 338 Location: Mumbai 
  | 
		  
		    
			  
				Hi
 
 
I have been able to figure out how to use the QueryString and how to specify a model for the HTTP POST (in case it contains an XML).
 
 
I need advice on how to model the REST resource conventions. For example, i need to support a dynamic URL such as the following 
 
 
   
	| Code: | 
   
  
	
 
/find_account/:type/:key.xml
 
 | 
   
 
 
 
Sample URI's 
 
 
   
	| Code: | 
   
  
	
 
/find_account/RET/100011.xml
 
/find_account/CRP/100022.xml
 
 | 
   
 
 
 
As you can see, there is no QueryString, & I need to parse the RequestURI to get the value of :type & :key variables and then use them in by Mapping Node/ESQL. 
 
 
Is there a way to model these in IIB9 (or the upcoming IIB10?) ? Or should I just go ahead and parse the URI? _________________ Regards | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | smdavies99 | 
		  
		    
			  
				 Posted: Sat Jul 19, 2014 6:21 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Jedi Council
 
 Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land. 
  | 
		  
		    
			  
				Have you looked at the trace node output for 
 
 
${Root} 
 
 
and
 
 
${LocalEnvironment}
 
 
for your test messages? some of what you want may already be there. _________________ WMQ User since 1999
 
MQSI/WBI/WMB/'Thingy' User since 2002
 
Linux user since 1995
 
 
 
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | akil | 
		  
		    
			  
				 Posted: Mon Jul 21, 2014 3:13 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Partisan
 
 Joined: 27 May 2014 Posts: 338 Location: Mumbai 
  | 
		  
		    
			  
				Hi
 
 
Yes , the RequestURI contains the path which can be tokenised by splitting on the '/' separator.. but this code can quickly get complicated if I need to handle nested resources and id's ... I was looking for some pattern / available convention / code to do this ..  Have started wiring it up myself for the moment, will share the code on github shortly , in case anyone needs it.. _________________ Regards | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | 
		    
		   |