Service enabling WebCenter Interaction

Today, I needed to create a web service to expose some functionality from WebCenter Interaction.  In this case, I needed to be able to have an external process move a document from one folder to another in the knowledge repository.

While this could be done by simply updating a record in the database, I wanted to create a web service using the WebCenter Interaction APIs.

I have WebCenter Interaction 10gR3 running on Oracle WebLogic Server 10.3, so I will do my development in Oracle Workshop for WebLogic.  To start, create a new Project of type Web Service Project, and add it to a new EAR file.

In the wizard, unselect the following libraries:

  • beehive-controls
  • weblogic-controls
  • wls-common-logging-bridge

Now open the Java Resources folder, and right click on src and create a new package called “test” or whatever you like.  You need a package to contain the web service files.

Right click on your new package and create a new WebLogic Web Service.  I called mine “TestMoveDoc.”

We need to add some libraries so that we will be able to compile and run our code.  The libraries we need are in our WebCenter Interaction install directory, in my case it is c:\bea\alui\ptportal\10.3.0\lib\java.  We need to add the libraries into the WEB-INF\lib directory under WebContent.  Navigate to the lib directory, right click on it, and select Import.

In the import dialog, enter the from directory (or browse to it).  You should see a folder called java appear in the left hand side of the dialog.  Click on it to highlight it.  You will see a list of libaries (jar files) appear on the right.  We need the following:

  • connectionpool.jar
  • dbutils.jar
  • opencache.jar
  • openconfig.jar
  • opencoutners.jar
  • opendb.jar
  • openfoundation.jar
  • openhttp.jar
  • openkernel.jar
  • openkernelsearch_4-3.jar
  • openlog-framework.jar
  • opentempfile.jar
  • plbase.jar
  • ploracle.jar  (I am using an Oracle database for WebCenter Interaction)
  • plumtreeserver.jar
  • plutil.jar
  • pmb.jar
  • ptportalobjects.jar
  • xercesImpl.jar

The libraries that I have highlighted in italics are the ones we directly need, the others are all dependencies.

Now we are ready to write the code for our web service.  The web service designer should still be on the screen.  Click on the hello() service to open the editor.

You can rename the service by changing its name in the code editor, I changed mine to moveDocument.  Here is the code that I used:

package test;

import javax.jws.*;

import com.plumtree.openkernel.config.IOKContext;
import com.plumtree.openkernel.factory.OKConfigFactory;
import com.plumtree.server.IPTCatalog;
import com.plumtree.server.IPTSession;
import com.plumtree.server.PortalObjectsFactory;

@WebService
public class TestMoveDoc {

    @WebMethod
    public String moveDocument(MoveDocumentRequest request) {

        IOKContext context = OKConfigFactory.createInstance
           ("c:\\bea\\alui\\settings", "portal");
        PortalObjectsFactory.Init(context);
        IPTSession session = PortalObjectsFactory.CreateSession();
        try {
            // userid and password are the parameters
            session.Connect("administrator", "welcome1", null);
        } catch (Exception e) {
            //TODO handle this
        }
        IPTCatalog catalog = session.GetCatalog();
        catalog.MoveCards(request.getSourceFolder(),
           request.getDocumentId(),
           request.getTargetFolder(), 2, true);
        // clean up
        catalog = null;
        session = null;
        context = null;
        return "DONE";
    }
}

You will notice that I created a simple bean class, MoveDocumentRequest, to hold the inputs to the service.  Here is the definition of that class, you can add it to the same package as the web service (right click on package, New, Java Class).

package test;

public class MoveDocumentRequest {

    private int documentId;
    private int sourceFolder;
    private int targetFolder;

    public MoveDocumentRequest() {
        super();
        // TODO Auto-generated constructor stub
    }
    public int getDocumentId() {
        return documentId;
    }
    public void setDocumentId(int documentId) {
        this.documentId = documentId;
    }
    public int getSourceFolder() {
        return sourceFolder;
    }
    public void setSourceFolder(int sourceFolder) {
        this.sourceFolder = sourceFolder;
    }
    public int getTargetFolder() {
        return targetFolder;
    }
    public void setTargetFolder(int targetFolder) {
        this.targetFolder = targetFolder;
    }
}

To deploy this to the server, you right click on the EAR project, and select Export, EAR file with JSP pre-compilation, save it as TestMove.ear (or whatever you like), and then deploy it using the WebLogic Server console.

You can also obtain the WSDL location from the WebLogic Server console, and from there you can test it or consume it as needed.

About Mark Nelson

Mark Nelson is an Architect (an "IC6") in the Fusion Middleware Central Development Team at Oracle. Mark's job is to make Fusion Middleware easy to use in the cloud and at home, for developers and operations folks, with special focus on continuous delivery, configuration management and provisioning - making it simple to manage the configuration of complex environments and applications built with Oracle Database, Fusion Middleware and Fusion Applications, on-premise and in the cloud. Before joining this team, Mark was a senior member of the A-Team since 2010, and worked in Sales Consulting at Oracle since 2006 and various roles at IBM since 1994.
This entry was posted in Uncategorized and tagged , . Bookmark the permalink.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s