This post outlines a methodology to expose RESTful services for some of the common tasks of Lombardi like, process initiation and adding comments to a process instance taking them as examples. Any API call from Lombardi which needs to be exposed as REST should be exposed as a SOAP Webservice, since Lombardi does not provide the capability to directly expose the API calls as RESTful service. If a BPD needs to be invoked, a general system service needs to be exposed as SOAP Webservice. The actual instantiation of the process should happen with the general system service.
For example, a BPD can be invoked using the following command, embedded in a Server script activity of general system service.
// to start a process
var processInstance = tw.system.startProcessByName(processName, InputParameterMap);
// to add comment to a process instance
var processInstance = tw.system.findProcessInstanceByID(processId);
processInstance.addComment("Hello!");
Lombardi provides a Webservice implementation component which can be used to expose general system service as SOAP Webservices. A stand alone service layer built on Spring3 framework would consume the SOAP Webservices and convert them to RESTful services using Spring3 REST support. Stand alone services can decouple the transformation logic from Lombardi. Also, deploying them as stand alone would mean that Lombardi product code is not tinkered and hence not endangering future product patches and also this helps fully leveraging Lombardi warranty support.
Below are the examples of code snippets of Spring controller which calls a SOAP Webservice (Lombardi API exposed as SOAP Webservice) and exposes the method as RESTful service which would emit XML or JSON.
// controller method to invoke a process
@RequestMapping(method = RequestMethod.GET, value = "/startCalcGDPProcess",
headers = "Accept=application/xml, application/json")
public @ResponseBody
String startCalcGDP() throws Exception {
RunGDPPortTypeProxy proxy = new RunGDPPortTypeProxy();
String pi = proxy.startGDP();
return pi;
}
// controller method to add a comment to a process instance
@RequestMapping(method = RequestMethod.POST, value = "/addCommentToGDP",
headers = "Accept=application/xml, application/json")
public ModelAndView addCommentToGDPProcess(@RequestBody String body) {
Source source = new StreamSource(new StringReader(body));
ProcessInstance e = (ProcessInstance) jaxb2Mashaller.unmarshal(source);
addCommentToGDPProcess.add(e);
return new ModelAndView(XML_VIEW_NAME, "object", e);
}
A sample Spring servlet configuration for REST based services.
<!-- To enable @RequestMapping process on type level and method level -->
<bean
class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" />
<bean
class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="messageConverters">
<list>
<ref bean="marshallingConverter" />
<ref bean="atomConverter" />
<ref bean="jsonConverter" />
</list>
</property>
</bean>
<!-- Client -->
<bean id="restTemplate" class="org.springframework.web.client.RestTemplate">
<property name="messageConverters">
<list>
<ref bean="marshallingConverter" />
<ref bean="atomConverter" />
<ref bean="jsonConverter" />
</list>
</property>
</bean>
<bean id="jaxbMarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
<property name="classesToBeBound">
<list>
<value>dw.spring3.rest.bean.ProcessInstance</value>
</list>
</property>
</bean>
<bean id="lombardiRestAPI"
class="org.springframework.web.servlet.view.xml.MarshallingView">
<constructor-arg ref="jaxbMarshaller" />
</bean>
<bean
class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
<property name="mediaTypes">
<map>
<entry key="xml" value="application/xml" />
<entry key="html" value="text/html" />
</map>
</property>
<property name="viewResolvers">
<list>
<bean class="org.springframework.web.servlet.view.BeanNameViewResolver" />
<bean id="viewResolver"
class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
</list>
</property>
</bean>
<bean id="marshallingConverter"
class="org.springframework.http.converter.xml.MarshallingHttpMessageConverter">
<constructor-arg ref="jaxbMarshaller" />
<property name="supportedMediaTypes" value="application/xml" />
</bean>
<bean id="atomConverter"
class="org.springframework.http.converter.feed.AtomFeedHttpMessageConverter">
<property name="supportedMediaTypes" value="application/atom+xml" />
</bean>
<bean id="jsonConverter"
class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter">
<property name="supportedMediaTypes" value="application/json" />
</bean>
This approach might sound little bit awkward for having a RESTful service invoking a SOAP Webservice, however this methodology effectively decouples the Lombardi API calls from generating RESTful services.
32 comments:
Interesting, and valuable to those that may need the extra flexibility.
However, my first thought is that you should be using the existing RESTAPI that is available from the community on the wiki. This works great for v7.2.
And under 7.5 there are even more options! under 7.5 the RESTAPI is actually product.
The RESTAPI allows you to directly call teamworks services through a simple url mapping. You can also do a million other cool things: run saved searches, inspect BPD internals, and more. Really, you've got to check this out.
Also under 7.5 Advanced, you can use Integration Designer to expose anything using SCA -- which then can map to rest, ajax, webservices, jms or just about anything else. SUPER configurable, and you don't need Spring to make it happen.
Write me if you want to know more - ted.gaunt@lucidtechnique.com
JSONP is supported in the IBM BPM 7.5 REST API.
For details, have a look at http://publib.boulder.ibm.com/infocenter/dmndhelp/v7r5mx/topic/com.ibm.wbpm.bpc.doc/topics/cdev_restapis_contenttypes.html
Excerpt:
JSONP responses (BPD-related REST APIs only)
To request that response data is to be returned in the JSONP format, you must specify a application/x-javascript response media type using either the Accept HTTP header or the accept URI parameter. You must also specify the JavaScript function name using the callback URI parameter. The response consists of the JSON content wrapped in a JavaScript callback function invocation. For example:
GET /rest/bpm/wle/v1/task/...?accept=application/x-javascript&callback=mycallback
Because of security considerations, support of JSONP is not enabled by default. To enable JSONP support, set the associated property in the 100Custom.xml file for the process server:
<jsonp-enabled>true</jsonp-enabled>
Content types supported by the IBM BPM REST APIs
Hey
Yes Under BPM 7.5 Rest API suppoprt is available out of the box. They allow you to direclty call Lombardi services
For process initiation for example
you can use the uri
String str="http://:/rest/bpm/wle/v1/process"
URI uri= new URI(str,true)
method.setURI(uri);
method.setURI("action","start");
method.setURI("bpdid","");
method.setURI("snapshotId","");
int statuscode=client.executeMethod(method);
and the default response is JSON
It’s really a nice and useful piece of info.
I’m satisfied that you simply shared this useful info with us.
Please stay us up to date like this. Thank you for sharing.For java developers we are offeringHybris Training
It fun to have a content like this really worth to read it
Teradata Training
games online klik di sini
cheat games online
http://www.sateayam.net/
http://bolavitasate.wikidot.com/blog:5
It become an attractive part of a blog when author uses indirect speech while writing a blog. It shows your creative mind as well as make your written essay different from others.cursus excel amsterdam
I see the greatest contents on your blog and I absolutely love reading them. Aloha Construction
The worst part of it was that the software only worked intermittently and the data was not accurate. You obviously canot confront anyone about what you have discovered if the information is not right. pressbusiness
This is an awesome motivating article.I am practically satisfied with your great work.You put truly extremely supportive data. Keep it up. Continue blogging. Hoping to perusing your next post pressbusiness
When your website or blog goes live for the first time, it is exciting. That is until you realize no one but you and your. business name generator
You possess lifted an essential offspring..Blesss for using..I would want to study better latest transactions from this blog..preserve posting.. Best Marketing blog
I am very much pleased with the contents you have mentioned. I wanted to thank you for this great article. Write for us business
Sometimes is becomes very hard to take appreciation for your hard work. But sometime only few technical point makes your work worthwhile. Suggestion under this blog is quite good.cursus excel amsterdam
I’ve been surfing online more than three hours today, yet I never found any interesting article like yours. It’s pretty worth enough for me. In my opinion, if all webmasters and bloggers made good content as you did, the web will be a lot more useful than ever before. small business seo
I wanted to thank you for this great read!! I definitely enjoying every little bit of it I have you bookmarked to check out new stuff you post. #1 digital agency
Nice post! This is a very nice blog that I will definitively come back to more times this year! Thanks for informative post. Blogging the boys
business name search Hello, you have outdone yourself this particular time. This is most likely the best, most succinct information out there on exactly how to create a strategy like this. Many thanks . By the way, if you need to name your company i created this business name generator application and it's cost-free online making business name search so easy.
Nice post! This is a very nice blog that I will definitively come back to more times this year! Thanks for informative post. Marketing1on1 in Los Angeles
This particular papers fabulous, and My spouse and i enjoy each of the perform that you have placed into this. I’m sure that you will be making a really useful place. I has been additionally pleased. Good perform! readymade website for sale
This is a great inspiring article.I am pretty much pleased with your good work.You put really very helpful information. Keep it up. Keep blogging. Looking to reading your next post. strawnana strain
Nice to be visiting your blog again, it has been months for me. Well this article that i've been waited for so long. I need this article to complete my assignment in the college, and it has same topic with your article. Thanks, great share. Organic ghee
It has fully emerged to crown Singapore's southern shores and undoubtedly placed her on the global map of residential landmarks. I still scored the more points than I ever have in a season for GS. I think you would be hard pressed to find somebody with the same consistency I have had over the years so I am happy with that. gobdarchivierung
Its's really nice job to done ,try to implement more set of ideas through it.keep share more.
C and C++ Training Institute in chennai | C and C++ Training Institute in anna nagar | C and C++ Training Institute in omr | C and C++ Training Institute in porur | C and C++ Training Institute in tambaram | C and C++ Training Institute in velachery
I’m satisfied that you simply shared this useful info with us.
Please stay us up to date like this. Thank you for sharingJava training in Chennai
Java Online training in Chennai
Java Course in Chennai
Best JAVA Training Institutes in Chennai
Java training in Bangalore
Java training in Hyderabad
Java Training in Coimbatore
Java Training
Java Online Training
Wow, this is really interesting reading. I am glad I found this and got to read it. Great job on this content. I like it. names for organization
i am always looking for some free stuffs over the internet. there are also some companies which gives free samples. cool company names
Great job here on _______ I read a lot of blog posts, but I never heard a topic like this. I Love this topic you made about the blogger's bucket list. Very resourceful. clothing line names
Wow! This could be one of the most useful blogs we have ever come across on thesubject. Actually excellent info! I’m also an expert in this topic so I can understand your effort. unique business names
I am glad you take pride in what you write. This makes you stand way out from many other writers that push poorly written content. creative business name
Post a Comment