Objects and web-services in jBPM - web-services

Is it possible to consume web-services and/or use own libraries (and thus custom objects) into a jBPM workflow? Eventually, could I expose this process as (another) web-service?

You can use web services in jBPM, at least in version 5 and 6. I believe the tooling support in eclipse is minimal or non-existent however. Don't know about the support in web console. See Maciej's blog for details on that.
It is possible to use custom objects and own libraries in jBPM. You just have to make the libraries available to the jBPM runtime. If you're using your own application where you run jBPM, just include the libraries in the CLASSPATH. For the jBPM console, you will have to include the libraries in the lib/ directory of the war, or inside WEB-INF/classes if you have .class files.
Not sure if there is out of the box support for exposing jBPM services over web service. If all you want to do is orchestrate other web services and expose yourself as a web service, you could consider using a BPEL engine rather, like Apache ODE

jBPM can call web services and contain custom libraries. A jBPM project is a Maven project, so you can add dependencies to your POM to include custom libraries. You can call web services or execute any custom Java code you want by creating a "Domain-specific process." There is an example in the documentation about how to do that: http://docs.jboss.org/jbpm/v6.0.1/userguide/jBPMDomainSpecificProcesses.html
Also, if you deploy your projects into the jBPM web console, they can be started and controlled by a REST API. So yes, they are exposed as a REST web service. See this page in the documentation about the REST API: http://docs.jboss.org/jbpm/v6.0.1/userguide/jBPMRemoteAPI.html
For example, the following REST call can initiate a process (taken from the link above):
[POST] /runtime/{deploymentId}/process/{processDefId}/start

Related

Having RESTful service in RCP application

We have an existing eclipse RCP application that works as a standalone product. At a high level, this product is used to configure a image specification using its UI and we can export a sample Image based on these configuration.
Now we are developing another web application that has several modules and one module of it is to develop something that our eclipse RCP application does.
Just to provide a QUICK integration of the RCP application for demo purpose, I plan to run the RCP application separately in the server machine and expose its static functionality as a RESTful webservice. So the module shall make a RESTful call to the RCP application.
Now just to begin with I tried to embed a jetty server for hosting the REST service during the start of RCP application like below
But the thing is after the Jetty server is started I am not able to access the TestWebService using the path i configured. So I am confused if this is the right approach to have a RESTful service inside a RCP application. Please note that iam able to hit the server with http://localhost:1002, but not the service.
Following is the console log when i hit on http://localhost:1002/hello/test:
It's a really weird architecture you're experimenting with.
I mean to write an RCP-application which listens on a port and offers REST services on it; this could lead to further obstacles.
Instead I would seperate it into two software artifacts: an RCP-app and a web-application (.war).
You could extract a business-logic jar (It can be an OSGi plug-in if necessary) contaning your image manipulation logic.
Then include this plug-in/.jar as a dependency in the webapp and offer out it's functionalities thru a Web-container (Tomcat, GlassFish, etc.)
So your other (third) application will connect to the Web-services offered by this .war file.
opt.1) If you need a single running instance (because of database or other shared resource) then your RCP-app will have to use this REST service too.
opt.2) If not then simple compile the .jar/plug-in containing the business-logic into your RCP-app.

Libraries rather than Web Services

I am interested in the pros/cons of refactoring a large application (industrial monitoring software) into a bunch of Libraries / NuGet Packages, rather than as stand-alone Services. The perception is that they're almost identical, i.e. a service can be built as either a Library hosted within the application, or it can be built as a Web Service and hosed externally to the application. The only difference is integration (code level vs. network SOAP or REST traffic). I'm not sure it's that straightforward, looking for pros/cons of each.
The perception is that they're almost identical...
If you squint your eyes hard enough I think they might look identical. But only up to a point.
You implement some functionality in a web service, you can implement it in a library too. The web service
provides an API to call, the library provides an API to call too. You invoke the web service, you can invoke
the library too.
But there is stuff you can't do by replacing a web service with
a library.
Your libraries are in .dll files? How is a PHP application going to use them? Or a Java application? SOAP/REST are client agnostic. Your web service can use any technology stack, your client can use any technology stack.
With libraries you are stuck to the same technology you used to write the library in.
Web services are individually deployable components. Fix bugs for the web service, deploy, and your 10 clients get the fix on the next call. Now fix some bugs for the library then update all 10 clients to use
the new versions of the libraries.
How about security? A web service can have a database for example. You don't get access to the database directly, you do so
with the API the web service provides you. You have a library that uses a database? Guess where the connection
string, username and password are found.
How about scalability? If you have a web service you can scale it horizontally and your clients immediately benefit
from the improvement. If the library is in the client how are you going to scale it? By scaling the clients?
You can find similar responses elsewhere (e.g. Web Service vs. Shared Library), but the point to take home is that it depends on what you are building and for whom. One is not a general replacement for the other, and vice-versa.
If you are building a single monolithic application that makes use of all of these components then maybe it does not matter for you if the components are microservices or hosted libs. With libs it might actually be easier to build. But if your plan is to actually provide services to other clients, then hosted libs won't work all the way.

JAX-WS Web Services on Tomcat 8 – JAX-WS Library Files Location?

For a normal JSP web-app that provides web-services, where should the JAX-WS library jar files be placed?
<tomcat-home>/lib
or
<web-app>/WEB-INF/lib
and why?
In general, when are library files considered part of the container infrastructure or part of the web application?
DETAILS
I have implemented various JAX-WS web services following, among others, these guides:
https://jax-ws.java.net/2.2.10/docs
https://jaxenter.com/creating-soap-web-services-using-jax-ws-117689.html
http://www.mkyong.com/webservices/jax-ws/deploy-jax-ws-web-services-on-tomcat/
http://examples.javacodegeeks.com/enterprise-java/jws/jax-ws-web-services-on-tomcat/
http://www.java2blog.com/2013/03/jaxws-webservice-deployement-on-tomcat.html
Whilst the above guides were useful, there are differences in terms of both the required JAX-WS library jar files and where the JAX-WS library jar files should reside.
By trial and error, for JDK 1.8, Tomcat 8.0.30 & JAS-WS 2.2.10, this is the list of JAX-WS library jars that seem to be required:
gmbal-api-only.jar
ha-api.jar
jaxb-core.jar
jaxb-impl.jar
jaxws-api.jar
jaxws-rt.jar
management-api.jar
policy.jar
stax-ex.jar
streambuffer.jar
I am aware that the JDK contains some of the JAX-WS classes but these seem to be meant for standalone Java apps
ie all of the above jar files seem to be needed to avoid a ClassNotFoundException etc.
I have read the Tomcat 8 class-loader how-to
and appreciate that there is a parent-tree, hierarchal class loader and that jar files in:
<web-app>/WEB-INF/lib
are only available to that web app ie are hidden from other web apps
causes the app war file(s) to be bloated as each web app has it’s own copy
and that jar files in:
<tomcat-home>/lib
are available to and shared by all web apps
forces all web apps to use the same version of the library
libraries must be inter web-app shareable ie no statics, thread-safe etc
enables lookup via a JNDI Resource Factory eg JDBC, mail etc
suppresses memory leaks for DriverManager eg JDBC
The web services seem to work when the JAX-WS library jar files are in either location.
Looking at the Metro JAX-WS project,
where the JAX-WS library jars must be downloaded from, for now, I have put these into <tomcat-home>/lib as that is consistent with the ‘install’ option in the ant file.
As a general rule, I try not to pollute the web-container / app-server with unnecessary library jar files where possible as this can lead to conflicts for other web-apps that have to use a specific version of a required library.
Thanks for reading.
Had the same issue trying to deploy a web service to my local tomcat installation. I went the route of adding the jars you listed to get it going, but see the instructions of what's needed from Apache:
https://tomcat.apache.org/tomcat-8.0-doc/extras.html#Web_Services_support_(JSR_109)
...which I think will go a long way to minimizing the amount of jars that end up in your Tomcat's lib folder.

Libraries for creating a 'stand alone' Web Service deployed as a single binary

I want to create a simple web service which I shall then make available to third parties to host. The third parties will want to host the service as part of their own systems be that Windows, Linux or Solaris. They will want the web service to be made available to them as a pre compiled binary which they can run without dependencies on further third party software other than the OS itself.
So I am looking for a library, preferably in C / C++, which I can use to create a stand alone web service. I don't want to buy, install configure and manage some Application Server middleware such as Web Sphere, nor do my customers. I am happy to have a RESTFUl service rather than using SOAP.
I'm sure there are more than options available each with their own pro's and con's. A comparison of the options would be fantastic.
Regards
You may want to take a look at Webtoolkit (or 'wt'): www.webtoolkit.eu

Consuming a web service with the Netbeans Platform

I have an application that is written with the NetBeans Platform 5.5. I'm having trouble consuming a web service.
If I create a Java SE application in NetBeans, I can add a web service reference without problem.
Since my application is using the NetBeans Platform, many of the menu choices change. So, I cannot figure out how to add a reference to the web service. I've googled this topic a number of ways but haven't found any pages that deal with consuming a service through the platform. They all talk about consuming a service with a Java SE application.
Changing the application from the Platform architecture is not an option.
Here is a good tutorial for setting up a Feed Reader on NetBeans Platform. It covers some of the configuration issues for using web services
Blog with an entry about making a web services client
I'd be happy to try and give you a more specific answer if you can give information about the service you want to access.
Found this:
Create web service and client using this tutorial
Create library wrapper module for web service client (you don't need to include JAX-WS libs, only your client jar)
In your wrapper module add following dependencies (important):
JAX-WS 2.1 API
JAX-WS 2.1 and JAXB 2.1 Library (for this you have to check Show Non-API Modules in "Add Module Dependency" window)
If you try to build module after these steps it will fail telling you that your module is not friend of "path-to-netbeans"/java2/modules/org-netbeans-modules-websvc-jaxws21.jar.
Right click on JAX-WS 2.1 and JAXB 2.1 Library and choose Edit. Select Implementation Version.
from here.