Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
stefan_henke
Advisor
Advisor
6,666

In this blog, I would like to introduce you to a project in the context of NetWeaver Business Process Management (BPM) which is hosted on Code Exchange. You can find it at [1]. The project is about a RESTful service for NetWeaver BPM which is completely built on the BPM API that has been published with the 7.30 release of NetWeaver. The idea was to design it as generically as possible, so that it can be used in various scenarios.

The project should serve as a guide on how the new BPM API can be used to extend the functionality of NetWeaver BPM for additional requirements that are not yet covered by BPM out of the box. As the project is hosted on Code Exchange, the source code is publicly available in the Subversion (SVN) system. Feel free to take a look into it. It covers all of the features that the BPM API [2] offers: Simple retrieval of Task Instances, changing the status of a Task Instance, starting new Process Instances, and much more.

However, there are also other things that the project wants to prove. The open source project Apache CXF [3] is used for provisioning the RESTful service. It is a generic framework which, among other things, allows you to publish RESTful services from Java coding based on the JAX-RS standard [4]. In the project, you can see how you can use third party and open source libraries in your own applications.

Due to the Code Exchange guidelines, the project cannot be used in a productive environment. Regardless, in the current state the code is missing certain critical features that are required for a productive usage like sophisticated caching in the service to avoid unnecessary calls of the BPM API, the possibility for batch processing (mass operations) etc.

In summary, you can find the main features of the project as follows:

  • Provides remote access to most common entities of NetWeaver BPM
  • Supports not only read-only retrieval scenarios, but also write operations
  • Based on the public NetWeaver BPM API (introduced with 7.3 release)
  • RESTful service using HTTP binding which allows easy consumption on various platforms (for example, on mobile platforms)
  • Implemented as JAX-RS  service using Apache CXF to provide support for RESTful service
  • Runs on a NetWeaver AS Java 7.3
  • Supports XML as well as JSON for data transfer

To get started, you need to refer to the two discussion threads in the Discussion area of the project: The first that explains how to download a released version of the project. For this you do not have to connect to SVN, but can directly download the SCAs for deployment. Details can be found at [5]. The second Discussion thread explains how to get the source code from SVN into the NetWeaver Developer Studio. You must consider this option to inspect the coding or contribute to the project. Details can be found at [6].

The RESTful service consists of two productive Software Components, JAX-RS and BPEM-RESTSVC, which must be deployed to the AS Java.

JAX-RS

This SC contains the deployable archives of the Apache CXF framework which is used for RESTful service provisioning. Additionally, it exposes the JAX-RS API to build against. There is no source code in the SC, therefore you won´t find any java files in SVN. As the CXF archives are not stored in SVN, you have to first download them and add them yourself. This is described in one of the threads mentioned above.

BPEM-RESTSVC

This SC contains the NetWeaver BPM RESTful service itself. It has dependencies to the SC BPEM-FAÇADE exposing the BPM API as well as JAX-RS and contains all Java coding of the project.

Once you have installed the components, you might wonder how to use and access the functionality. To give you a complete overview about the HTTP resources exposed by the RESTful service, there is a technical reference guide available at [7]. It contains the technical details of how the different aspects of HTTP (like URL, method, headers, and bodies) are to be configured for individual requests. Though it contains you all the required information, the document is not meant to give you a step-by-step guide for introduction. I´m going to publish another blog that contains a tutorial for the BPM RESTful service in the next few days.

So, stay tuned.

 

[1] https://cw.sdn.sap.com/cw/groups/bpm-rest-api

[2] http://help.sap.com/javadocs/NW73/SPS03/CE/bpem/com.sap.bpem/index.html

[3] http://cxf.apache.org/

[4] http://jcp.org/en/jsr/summary?id=311

[5] https://cw.sdn.sap.com/cw/message/51605#51605

[6] https://cw.sdn.sap.com/cw/message/50805#50805

[7] https://cw.sdn.sap.com/cw/docs/DOC-146067

21 Comments
lvhengel
Active Participant
0 Kudos
Hi Stefan,

Thanks for this blog and mentioning this great Code Exchange project.
I have been investigating the SAP BPM API in the recent weeks on my NetWeaver 7.3 system and this Restful service is exactly the part i am looking for. I want to connect my BPM Tasks to other UI technologies (not the standard provided ones) and this service save me a lot of time writing my own Java code for the BPM API part.

Looking forward to your next blog.

Cheers,
Leo

P.S. How do you see the this service in context with the upcoming WS-HumanTask support in NetWeaver BPM? Also very curious when the WS-HumanTask support will be released 😉
stefan_henke
Advisor
Advisor
0 Kudos
Hi Leo,
thanks for the nice feedback. I´m going to publish the next blog today or latest tomorrow. Your question regaring WS-HT, I cannot say much. The RESTful service is only a prototype which will not be part of the Netweaver BPM product in this way. As far as I know, WS-HT does not describe a RESTful interface for accessing tasks, but only a SOAP-based on. However, the BPM API already makes use of the WS-HT terminology for task actions and status. I would see the alignment more on this level as this is the interface to BPM external applications can use.
Regards,
Stefan
lvhengel
Active Participant
0 Kudos
Hi Stefan,

Thanks for your reply. I see that your new blog is already online. In the meantime i downloaded and installed the RESTful BPM service on a local NW73 system and got it working. It works great! I already built a small demo with a simple HTML/JQuery UI which i will demo tonight to other NetWeaver collegues 🙂

Regards,
Leo
stefan_henke
Advisor
Advisor
0 Kudos
Hey Leo,
that´s great to hear that you already have a small demo based on the service. If you don´t mind, it would be great to share this on SDN for example in a blog.
Regards,
Stefan
0 Kudos

Hello Stefan and Leo,

I am trying to deploy the Sample SCs given on CodeExchange.

I have read all the blogs related to that on SDN.

Leo ,As the reply you gave me on your blog,  https://cw.sdn.sap.com/cw/message/70972#70972

.

I have tried to call the Service from RESTclient but it is giving me message below.

404   Not Found
SAP NetWeaver Application Server

  Error: Request cannot be processed.

  SAP Technology Troubleshooting Guide

Details:
Requested resource [BPMRestService] is not found.

So what can be the problem ?

Thank you in advance.

Regards,

Dixit.

stefan_henke
Advisor
Advisor
0 Kudos

Hi Dixitkumar,

could you mention which SCAs exactly you deployed? Maybe you missed one. For the RESTful service you require the following ones: JAXRS and BPEMRESTSVC

On the AS Java you can check in the NWA if the application 'tc~bpem~facade~rest~ear' is running. Just enter 'start' in the search field to find this view. The application should be in status 'started'.

Best regards,

Stefan

0 Kudos

Hello Stefan,

I deployed both JAXRS and BPEMRESTSVC.Also did the change on NWA and It is started.

But while calling it is giving 404 error only.

Regards,

Dixit.

stefan_henke
Advisor
Advisor
0 Kudos

Hi Dixit,

I noticed in your screenshot that you used upper case for specifying the url. Try to use only lower case. I think, the AS Java is differentiating here:

http:<host>:<port>/bpm/bpemservices/processdefinitions

Hopefully this will work out.

Best regards,

Stefan

0 Kudos

Hi Stefan,

I actually used lower case only.In responce it is automatically giving the error in uppercase.

Kind Regards,

Dixit.

stefan_henke
Advisor
Advisor
0 Kudos

Hi Dixit,

can you check if you find anything in the trace files. Either in the 'developer traces' or in the 'http log'. Which version of the AS java (and which usage type) are you using?

Best regards,

Stefan

0 Kudos

Hello Stefan,

I have cheked the traces and http log.

now it is giving  "Caused by: java.lang.ClassNotFoundException:org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet "

earlier it was "ServletNotFoundException".

Regards,

Dixit.

stefan_henke
Advisor
Advisor
0 Kudos

Hi,

I think you missed to add the CXF jars to the SCA. Unfortunately, the SCAs that can be downloaded from CodeExchange are not ready to be deployment. This is due to legal restrictions on CodeExchange.

Follow the steps here:

https://cw.sdn.sap.com/cw/message/51605#51605

After this it should work fine for you.

best regards,
Stefan

0 Kudos

Hello Stefan,

Is this the link for "how to deploy" blog on code Exchange ??

because I am not able to open this link.

Also I have already followed all the steps of "how to deplyo" post.

Should all the jars file be the same as in the blog or new version of the jar files should also work?

Thank you.

Regards,

Dixit.

stefan_henke
Advisor
Advisor
0 Kudos

Hi Dixit,

yes, it is on CodeExchange. But it looks like you already covered the steps described there. To be hontest, I once tried it with CXF 2.4.x, but failed with it. I cannot exactly remember the error. However,if you switch to another version, you also have to adjust the public part definitions in the SCAs. That is most likely the cause for your error. So, I would recommend to stick to the described version of CXF.

Best regards,

Stefan

0 Kudos

Hello Stefan,

I tried with the same virsion as given in the blog and it seems there was only jaxrs file was not same as required.

Thank you.

Best regards,

Dixit.

0 Kudos

Hello Stefan,

thank you for all the answers.They were really helpful.

 

          Now I want to start a process instance for which steps are

                    ->get process defination.

                    ->get process start event for that defination.

                    -> start the process.

          so in first step while getting process defination using vendor, dcName and process name it is giving me error 404.that i tried without vendor,dcName and process name so it gave me all the process definations. from that i took the one i needed and called the 2nd step for getting process start event that is giving me error "500 internal server error.". that i checked in SAP NWA -> http logs and traces that shows me "IllegalArgumentException" for method URI.create(String id).

So what can be the problem ?

Thank you again.

Regards,

Dixit.

stefan_henke
Advisor
Advisor
0 Kudos

Hi Dixit,

first of all, when getting the process definition, it is important to know that dc and vendor names have to be slightly converted in some cases. For example, if you have a '/' character in your name, you have to replace it by '~'. This is due to the fact that the process is built using the  NWDI by the Process Composer. Knowing this, your query should work.

Can you post the URI you are using to access the process start event? Are you using the 'simple id' or the uri of the event starting with 'bpm://....'? Try using the simple if which is the last segment of the uri starting with 'bpm://....' or you have to encode the uri. There is an example in the blog here: stefan.henke/blog/2011/11/14/getting-started-with-the-restful-service-for-netweaver-bpm

Best regards,

Stefan

0 Kudos

Hello Stefan,

          I am using the queries as follow..

../bpm/bpemservices/processdefinitions?vendor="abc.com"&dcName="xyz or fi_boo"&processName="fi boo"

with all the headers..

do i need to change anything(white spaces or dot) ?

and when i call -->  ../bpm/bpemservices/processdefinitions with all headers..

it is returning list of all processes in which the process which I need is there and when i use Id of that process just Id or full URI it is giving the exception as i said earlier.

Thank you.

Regards,

Dixit.

stefan_henke
Advisor
Advisor
0 Kudos

Hi,

you should not use hyphen (' " ') at the beginning and end of a value. This will cause an issue. Whitespaces have to be encoded using %20. Dots are fine as far as I know, but slashes again have to be converted to ~. I think it would make sense to document these guidelines.

Regards,

Stefan    

0 Kudos

Hello Stefan,

     Now I am trying to call the startprocess :

Method : PUT

URL (relative) : …/bpm/bpemservices/processstartevents/<processstarteventid>

Request Header -->

Authorization : <According to your settings>

Content-type : application/xml

Accept : application/xml

then it is giving the error as follow :

405 Method Not Allowed

Response Headers

Allow          POST,GET,OPTIONS,HEAD

Content-Length          0

Content-Type          text/xml

...

Thank you.

Regards,

Dixit.

Former Member
0 Kudos

Hello Stefan,

I am trying to get Output dataObject of a completed task but it is giving 500 internal server error.

"../bpm/bpemservices/taskinstances/taskinstance ID/output?schema=false".

in server traces the error is : "Exception raised from invocation of public com.sap.bpm.tm.api.TaskDetail com.sap.bpem.tm.impl.TaskInstanceManagerBean.getTaskDetail(java.net.URI) throws com.sap.bpm.exception.api.BPMException method on bean instance com.sap.bpem.tm.impl.TaskInstanceManagerBean ...nested exception is: java.lang.IllegalArgumentException: There is no old int value for a generic Data Container. This method should not have been called! ...".

What can be the issue here?

Thank you.

Regards,

Dixit.