Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
hofmann
Active Contributor

SUP is not just for SAP. It’s for mobilizing your business, no matter what you use to run your business. Today a business should use services as enables, and SUP offers a wide range of connectivity options to connect to these services: one is web service (WS). Now having a rather bad reputation, web services once where the Holy Grail. The nice thing about them is, that everything is capable to expose its information as a web service. So why not connect SUP to a web service instead of a BAPI? And as almost every technology can product a web service, why not create one?

Remarks

This blog is not about a specific mobile app, process or scenario, only about creating MBOs based on web services and connect SUP.

Pre-requisite is that the WS backend can be accessed by SDK and SUP. How the WS is accessed depends on your specific setup. Depending where the web service is running – on your local computer, on AWS or any other server - the connection profile changes. Here, the WS runs on the local machine and on the SUP instance. This allows for testing WS and MBO configuration without being connected to SUP. For the connection profile the WS server name must be accessible from the corresponding client (SDK or SUP).

Create Web Service

I decided to write a small and simple Java application that exposes some information as a web service. My choice is Geronimo (hope steinermatt won’t take this personal as there is also the choice to use NWCloud for running the web service), EJB and JPA. Download Apache Geronimo and unpack into a directory. Then start it. Geronimo, as a Java application, needs Java, so make sure either install a JRE or use the one SUP provides:

set JAVA_HOME=C:\Sybase\UnwiredPlatform\JDK1.6.0_31-x64

You cannot just start Geronimo and expect that it works. Sybase is also using a Java server, and SUP uses port 9999, as does Geronimo for JMX. If you just start Geronimo without configuring it to work together with SUP, you get the following error:

         java.rmi.server.ExportException: Port already in use: 9999; nested exception is:

       java.net.BindException: Address already in use: JVM_Bind

       at sun.rmi.transport.tcp.TCPTransport.listen(TCPTransport.java:310)

       at sun.rmi.transport.tcp.TCPTransport.exportObject(TCPTransport.java:218)


You can now either change the port SUP uses or the port Geronimo uses. No surprise, I changed Geronimo’s JMX port. Open the file config-substitutions.properties (var/config) and change the number of the property PortOffset by an arbitrary number. For the following example assume the value entered is 10. Geronimo is up and running when you access the page http://localhost:8090 and see the start page.

Geronimo configuration

Now having Geronimo installed gives the application server needed to develop and deploy the service. As stated above, this example will use JPA, so a data source is needed to make the data persistent.

Create the data source

To make it easy I used derby as the database. Geronimo comes with all you need to set up a derby database out of the box plus it is an embedded DB, so no additional software install or configuration needed. Besides, this is only for testing and learning SUP, so there is no actual need to try it with a “real” DB and I won’t be surprised if derby isn’t one of the standard POC DB (after MySQL or PostgreSQL) out there.

Database pools

Two data base pools are needed (this is special to derby as OpenJPA will use JTA and a sequence table and using just one JTA definition won’t work. (The error message looks like “org.apache.openjpa.persistence.PersistenceException: The Transaction Synchronization Registry can not suspend the current transaction”).

Both pools point to the same underlying DB: SUPWSDB

  1. Create a DB named SUPWSDB

Start the Geronimo DB pool wizard from the Data source menu:

Select as DB type what you a going to use and what is configured. Here: Derby (comes ootb with Geronimo).

  1. The same for NoTxSUPWSDB

Result

SUPWSDB

NoTxSUPWSDB

Verify DB

Make sure that the DB exists.

The tables will be created automatically by OpenJPA.

Deploy application

Import the EAR application (can be downloaded from GitHub). Use the deploy application available on the left menu. Make sure the application is running. You can start applications by selecting the Applications (EAR)menu from the left side.

In the Geronimo log the EAR startup will manifest itself in a way like:

[startup] Deployed Application(path=C:\Dev\geronimo-tomcat7-javaee6-3.0.0\bin\SUPWS\EAR\1.0\car)

[EjbModuleImpl] createApplication.createdEjbSUP-WS-EJB.jar/UserBeanUserBeanDefaultStatelessContainer

[EjbModuleImpl] createApplication.createdEjbSUP-WS-EJB.jar/ProductBeanProductBeanDefaultStatelessContainer

[EjbModuleImpl] createApplication.createdEjbSUP-WS-EJB.jar/OrderBeanOrderBeanDefaultStatelessContainer

[EjbModuleImpl] createApplication.startedEjbSUP-WS-EJB.jar/UserBeanUserBeanDefaultStatelessContainer

[EjbModuleImpl] createApplication.startedEjbSUP-WS-EJB.jar/ProductBeanProductBeanDefaultStatelessContainer

[EjbModuleImpl] createApplication.startedEjbSUP-WS-EJB.jar/OrderBeanOrderBeanDefaultStatelessContainer

Test the web services

This EAR does not provide any user interface, only some web services. To know that the application was deployed successfully and that the web services are ready, access one:

http://server:port/supwsorder/OrderPortInterface?wsdl

The response should look like:

The web service is ready to be used. Now it’s time to fill the DB with data. Nothing better than to use the web services to do so. After all, they were created to store data. The SOAP UI project contains a test suite for creating the initial values. It assumes that the web services are accessible under localhost and port 8090.

After running the test suite the DB looks like:

That’s it: a Java EJB application that exposes its business logic via a Web Service. Let’s see if and how SUP can be connected to that web service.

Connect SUP SDK to Web Service

The SUP SDK can be connected to REST Web Services and “normal” web services (REST Web Service is for a blog to come). The web services created above are normal web services. In the connection details screen the WSDL is to be entered.

That’s it. The connection is configured:

This kind of connection configuration has to be done for all 3 web services:

To create now a MBO that retrieves the list of all users, it’s just drag & drop.

Connect SUP server to Web Services

While you successfully created a connection profile in your SUP SDK to the Geronimo Web Services, the SUP server is unaware of this. When you deploy the MBOs to SUP you will find out that you are unable to deploy the MBOs. You have to provide a server connection first.

This can be done from inside the deploy wizard or the SUP admin will create the connection for you. From inside the deploy wizard:

The SDK will make sure that the connections are correctly created at the SUP server. If you want to check this, logo on to SCC and check the connections created in the domain:

With the connection profile created in SUP, the MBOs are ready to be used. As you can see, SUP is not only for SAP, but for all systems that SUP can connect to.

2 Comments
Labels in this area