Best Practices from Oracle Development's A‑Team

Service enabling WebCenter Interaction

Mark Nelson


This post demonstrates how to expose WebCenter functionality as a web service.

Main Article

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:

# Copyright 2012 Oracle Corporation. # All Rights Reserved. # # Provided on an 'as is' basis, without warranties or conditions of any kind, # either express or implied, including, without limitation, any warranties or # conditions of title, non-infringement, merchantability, or fitness for a # particular purpose. You are solely responsible for determining the # appropriateness of using and assume any risks. You may not redistribute. 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.

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.Captcha