You are on page 1of 36

Technical/

Customizing EnterpriseOne

December 2013

Creating a Business Services Wrapper for an E1 Business Function


By Scott Beebe
Editor's Note: Scott Beebe, Worldwide Software, JDE ToolsPlus.com, shared with JDEtips this article that he had
previously posted on his own site. The article serves as a vital introduction to how to get your JDE system to play nice
with third-party web services and applications.

Business services is quickly becoming the preferred method of interfacing between third-party applications
and JD Edwards EnterpriseOne. Using business services you can expose web services functions to the
outside world to give other applications an industry standard method to interact with E1. Business service
functions also give you the opportunity to call third-party web services. Web services is becoming the
standard method for unrelated applications to interact with each other. In E1, business services is used to
publish and consume web services.
This article was written with the intent of providing you with a Hello World type of exercise to help you learn
how to build your first business service function. This example will walk you through creating a business
service function that will simply call an EnterpriseOne function. I call this a wrapper since it provides no other
functionality beyond just calling the function. The wrapper business service can then be published, allowing
an outside application to call your E1 business function.
Before starting this exercise, create a simple business function that takes an address number for an input
and returns basic address book info: Alpha Name, Address Line 1, Address Line 2, City, State, Zip, Date
Last updated, Time Last updated. This business function includes all the common data types that we will
normally deal with. The instructions below are the steps required to build a business services wrapper for
this function.
This document assumes that business services are properly setup on E1 development workstation. If trying
to walk through for a training exercise, you will need to change object and class names from this example.

Create the BSSV Functions That Will Be Needed


JP550001
This will be the published business services class.
1.
2.
3.

In OMW, click on Add.


Select the Business Function radio button, click OK.
Enter the following information on the next screen.
Object Name

JP550001

Description

Published Get AB Info

Copyright 2013 by Klee Associates, Inc.


www.ERPtips.com

Creating a Business Services Wrapper for an


E1 Business Function
Package Prefix

oracle.e1.bssv

Product Code

55

Product System Code

55

Source Language

BSSV

On the OMW-Business Function Design screen, click OK to return to OMW screen.


J550001
This will be the internal business service class that will be called from the published business services.
1.
2.
3.

In OMW, click on Add.


Select the Business Function radio button, click OK.
Enter the following information on the next screen.

Object Name

J550001

Description

Internal Get AB Info

Package Prefix

oracle.e1.bssv

Product Code

55

Product System Code

55

Source Language

BSSV

On the OMW-Business Function Design screen, click OK to return to OMW screen.

Start up JDeveloper and Set up the First Project (J550001)


1.
2.
3.

In OMW select J550001, click on the design button on the middle toolbar.
Click on the Invoke JDeveloper button.
When JDeveloper starts it will prompt to save selected files. This is normal; just click OK.

Copyright 2013 by Klee Associates, Inc. www.JDEtips.com

Page 2

Creating a Business Services Wrapper for an


E1 Business Function

4.

Create a new project to work with the new files we are creating. Right click on DV900 in the tree
view in the workspace pane, select New EnterpriseOne Project.

5.

If you dont see the next screen, just click on Next to get to it. Enter J550001 in the object name
field, click Find. Select J550001 in the grid, click on Finish. If prompted to override the existing
project file, click on Yes.

Copyright 2013 by Klee Associates, Inc. www.JDEtips.com

Page 3

Creating a Business Services Wrapper for an


E1 Business Function

Create the Value Object Class Based on BSFN Data Structure: Internal for
J550001
These value object classes are used as data structures to pass data to/from the business service functions.
1.

Find the new J550001 project in the tree view in the workspace pane on the right. Right click on the
J550001 project and select New from the popup menu.

Copyright 2013 by Klee Associates, Inc. www.JDEtips.com

Page 4

Creating a Business Services Wrapper for an


E1 Business Function

2.

In the tree view on the left, click on Classes under EnterpriseOne. Select Business Function Value
Object Class in the list on the right. Click on OK.

Copyright 2013 by Klee Associates, Inc. www.JDEtips.com

Page 5

Creating a Business Services Wrapper for an


E1 Business Function
3.

Click Next through this screen.

4.

Enter N550001 in the Object Name field, click on Find. Select the GetABInfo function in the grid,
click Next.

5.

This screen shows all of the elements from the data structure for the GetABInfo function. Since we
want to use all of the elements, select all of them. Click on Select All.

Copyright 2013 by Klee Associates, Inc. www.JDEtips.com

Page 6

Creating a Business Services Wrapper for an


E1 Business Function

6.

Give the value object a name and select Scope. This value object will not be published; it will only
be accessible to other functions on the BSSV server.
a. Enter InternalGetABInfo for the name.
b. Set Scope to be Internal.

7.

JDeveloper creates the new value object class based on the data structure members that you
selected. If you look at the file you will see each of the members defined in the class. You will
notice that all of them have been declared as private. That means they can only be accessed from
within the class itself. Standard practice is to make these elements private and then create public
functions that can be used to GET and SET these values. JDeveloper makes this easy.
a. Right click in the code page. Select Generate Accessors from the popup menu.

Copyright 2013 by Klee Associates, Inc. www.JDEtips.com

Page 7

Creating a Business Services Wrapper for an


E1 Business Function
b.

Select all of the data members in the Generate Accessors screen. Click OK.

Create the 2nd Project (JP550001)


1.

Create a new project to work with the new files we are creating. Right click on DV900 in the tree
view in the workspace pane, select New EnterpriseOne Project.

Copyright 2013 by Klee Associates, Inc. www.JDEtips.com

Page 8

Creating a Business Services Wrapper for an


E1 Business Function

2.

If you dont see the next screen, just click on Next to get to it. Enter JP550001 in the object name
field, click Find. Select JP550001 in the grid, click on Finish. If prompted to override the existing
project file, click on Yes.

Copyright 2013 by Klee Associates, Inc. www.JDEtips.com

Page 9

Creating a Business Services Wrapper for an


E1 Business Function
Create the Value Object Classes Based on BSFN Data Structure: Published
classes for JP550001
These value object classes are used as data structures to pass data to/from the business service functions.
JP550001 will be the published business service class. For this class we need to create two value object
classes. One will be used as the structure to send values to the business service. The second one will be
the structure in which the data values will be returned.
First value object class Input Class
1.

Find the new JP550001 project in the tree view in the work space pane on the right. Right click on
the JP550001 project and select New from the pop up menu.

2.

In the tree view on the left, click on Classes under EnterpriseOne. Select Business Function Value
Object Class in the list on the right. Click on OK.

Copyright 2013 by Klee Associates, Inc. www.JDEtips.com

Page 10

Creating a Business Services Wrapper for an


E1 Business Function

3.

Click Next through this screen.

4.

Enter N550001 in the Object Name field, click on Find. Select the GetABInfo function in the grid,
click Next.

Copyright 2013 by Klee Associates, Inc. www.JDEtips.com

Page 11

Creating a Business Services Wrapper for an


E1 Business Function

5.

This screen shows all of the elements from the data structure for the GetABInfo function. Only
select the data members that will allow input into the function. In our case only the address book
number is an input parameter.
a. Click on the check box next to mnAddressNumber.

6.

Give the value object a name and select Scope. This value object will be published.
a. Enter GetABInfo for the name.
b. Set Scope to be Publish.

Copyright 2013 by Klee Associates, Inc. www.JDEtips.com

Page 12

Creating a Business Services Wrapper for an


E1 Business Function

7.

JDeveloper creates the new value object class based on the data structure members that you
selected. If you look at the file you will see each of the members defined in the class. You will
notice that all of them have been declared as private. That means they can only be accessed from
within the class itself. Standard practice is to make these elements private and then create public
functions that can be used to GET and SET these values. JDeveloper makes this easy.
a. Right click in the code page. Select Generate Accessors from the popup menu.
b. Select all of the data members in the Generate Accessors screen. Click OK.

Copyright 2013 by Klee Associates, Inc. www.JDEtips.com

Page 13

Creating a Business Services Wrapper for an


E1 Business Function

Second value object class Return Class


1.

Find the new JP550001 project in the tree view in the work space pane on the right. Right click on
the JP550001 project and select New from the pop up menu.

Copyright 2013 by Klee Associates, Inc. www.JDEtips.com

Page 14

Creating a Business Services Wrapper for an


E1 Business Function

2.

In the tree view on the left click on Classes under EnterpriseOne. Select Business Function Value
Object Class in the list on the right. Click on OK.

Copyright 2013 by Klee Associates, Inc. www.JDEtips.com

Page 15

Creating a Business Services Wrapper for an


E1 Business Function
3.

Click Next through this screen.

4.

Enter N550001 in the Object Name field, click on Find. Select the GetABInfo function in the grid,
click Next.

5.

This screen shows all of the elements from the data structure for the GetABInfo function. Only
select the data members that will return values. In our case all but the Address number will be
output parameters.
a. Click Select All.
b. Deselect mnAddressNumber.

Copyright 2013 by Klee Associates, Inc. www.JDEtips.com

Page 16

Creating a Business Services Wrapper for an


E1 Business Function

6.

Give the value object a name and select Scope. This value object will be published.
a. Enter ReturnABInfo for the name.
b. Set Scope to be Publish.

7.

JDeveloper creates the new value object class based on the data structure members that you
selected. If you look at the file you will see each of the members defined in the class. You will
notice that all of them have been declared as private. That means they can only be accessed from

Copyright 2013 by Klee Associates, Inc. www.JDEtips.com

Page 17

Creating a Business Services Wrapper for an


E1 Business Function
within the class itself. Standard practice is to make these elements private and then create public
functions that can be used to GET and SET these values. JDeveloper makes this easy.
a. Right click in the code page. Select Generate Accessors from the popup menu.
b. Select all of the data members in the Generate Accessors screen. Click OK.

8.

The superclass for the two value object classes we just created need to be changed from
ValueObject to MessageValueObject. MessageValueObject is the typical value object superclass
for output value objects. It includes an E1MessageList for returning warning and informational
messages.
a. When the superclass is modified it will be underlined in red. The red means JDeveloper
doesnt know what it is.
b. Place your cursor over the superclass name. When the little blue popup shows up, hit AltEnter to import the file where MessageValueObject is defined
(oracle.e1.bssvfounation.base.MessageValueObject). Imports work the same as include
statements in C.
c. You will notice the new line in the import section at the top for the code screen.

9.

At the bottom of the RetrunABInfo class, add a new constructor as shown below. This class
already has a default constructor, but we will need this new special constructor later.

a. After creating the new constructor place your cursor over the InternalGetABInfo. After the
little blue popup shows up, hit Alt-Enter to import the file where InternalGetABInfo is
defined. This will be the new internal value object class we created earlier .

Copyright 2013 by Klee Associates, Inc. www.JDEtips.com

Page 18

Creating a Business Services Wrapper for an


E1 Business Function

Create the Internal Business Service Class: Internal for J550001


1.

Find the J550001 project in the tree view in the work space pane on the right. Right click on the
J550001 project and select New from the pop up menu.

2. In the tree view on the left click on Classes under EnterpriseOne. Select Business Service Class in
the list on the right. Click on OK.

Copyright 2013 by Klee Associates, Inc. www.JDEtips.com

Page 19

Creating a Business Services Wrapper for an


E1 Business Function

3.

Define the new business class. This class will not be published; it will only be accessible to other
functions on the BSSV server.
a. Enter ABInfoTest for the class name.
b. Enter getABInfoInternal for the new method name.
c. Browse for the input class. This will be the new internal value object class we created
earlier. Find the InternalGetABInfo value object class.
d. Click OK.

Copyright 2013 by Klee Associates, Inc. www.JDEtips.com

Page 20

Creating a Business Services Wrapper for an


E1 Business Function
4.

The new internal business service class will be generated with the get method. At this point the
class is just a skeleton and does nothing.

Create the Published Business Service Class: Published Class for


JP550001
5.

Find the JP550001 project in the tree view in the work space pane on the right. Right click on the
JP550001 project and select New from the pop up menu.

6.

In the tree view on the left click on Classes under EnterpriseOne. Select Published Business
Service Class in the list on the right. Click on OK.

Copyright 2013 by Klee Associates, Inc. www.JDEtips.com

Page 21

Creating a Business Services Wrapper for an


E1 Business Function

7.

Define the new published business class. This class will be published. A published business
service class requires an input value object class and an output value object class.
a. Enter ABInfoTestPub for the class name.
b. Enter getABInfo for the new method name.
c. Browse for the input class. This will be the new value object class we created earlier. Find
the GetABInfo value object class.
d. Browse for the output class. This will be the new value object class we created earlier.
Find the ReturnABInfo value object class.
e. Click OK.

Copyright 2013 by Klee Associates, Inc. www.JDEtips.com

Page 22

Creating a Business Services Wrapper for an


E1 Business Function

8.

The new published business service class will be generated with the get method. At this point the
class is just a skeleton and does nothing.

Add Some Code to Do the Work


At this point we have skeletons for all of the classes that we need. It will compile and run, but that is it. Now
we need to make it do something.
1.

Find the protected method GetABInfo in the ABInfoTestPub class.

2.

Find the TODOs in the skeleton code and add new code so it matches below.

//Create a new internal value object.


InternalGetABInfo internalVO = new InternalGetABInfo();
//Call BusinessService passing context, connection and internal VO
E1MessageList bssvMessages = ABInfoTest.getABInfoInternal(context,connection,internalVO);
//Add messages returned from BusinessService to message list for PublishedBusinessService.
messages.addMessages (bssvMessages);

Copyright 2013 by Klee Associates, Inc. www.JDEtips.com

Page 23

Creating a Business Services Wrapper for an


E1 Business Function

3.
4.

You may need to use Alt-Enter to add some imports for the new code. Do this for each object in
your code that is underlined in red.
Make the business service projects. Highlight each project and click on the Make button to compile.
Resolve any compile errors.

Copyright 2013 by Klee Associates, Inc. www.JDEtips.com

Page 24

Creating a Business Services Wrapper for an


E1 Business Function
Create a Test Class
We create a test class to make it easier to run the process over and over. It is very useful for
troubleshooting. Our business service classes dont really do anything yet, but it is a good time to create and
verify the test class works properly.
1.

Find the J550001 project in the tree view in the work space pane on the right. Right click on the
J550001 project and select New from the pop up menu.

2.

In the tree view click on General. Select Java Class in the list on the right. Click on OK.

Copyright 2013 by Klee Associates, Inc. www.JDEtips.com

Page 25

Creating a Business Services Wrapper for an


E1 Business Function

3.

Define the new Java Class we will use for testing.


a. Enter GetABTestClass for the class name.
b. Click on Generate Main Method.
c. Click OK.

4.

Add the following code to the new Java Class. Include testGetABInfo anywhere inside the class.

Copyright 2013 by Klee Associates, Inc. www.JDEtips.com

Page 26

Creating a Business Services Wrapper for an


E1 Business Function

public static void testGetABInfo() throws BusinessServiceException {


//instantiate the ABInfo class
ABInfoTestPub ABInfo = new ABInfoTestPub();
//Instantiate and/or declare the needed data structures
GetABInfo inputVo = new GetABInfo();
ReturnABInfo returnVo;
//Call the business service
inputVO.setAddressNumber(new Integer(3000));
book number for the test.
returnVo = ABInfo.GetABInfo(inputVo);

//Pick a valid address

//Output some info so we can see if it worked or not.


System.out.println("Message List");
System.out.println(returnVo.getE1MessageList().getMessagesAsString());
System.out.println("AB Info");
System.out.println(returnVo.toString());
}
Note: Be sure to add throws BusinessServiceException on the main declaration.

public static void main (String[] args)throws BusinessServiceException {


try {
TestBusinessService.startTest();
testGetABInfo();
}
finally {
TestBusinessService.finishTest();
}

5.
6.
7.
8.

Use Alt-Enter to add the import statements as needed. BusinessServiceException should use
oracle.e1.bssvfoundation.exception.
Click on Save
Make/Compile the new Java Class.
Click on Run to run the process.

Copyright 2013 by Klee Associates, Inc. www.JDEtips.com

Page 27

Creating a Business Services Wrapper for an


E1 Business Function

9.

We havent written any code to call the E1 business function or to pass values back and forth yet
so after all of this work so far it still pretty much still does nothing.

Create Code to Map Between Published and Internal Value Objects


Map from Published to Internal value object
We will create a method in our published value object class to map the published members to the internal
value object class so we can pass the needed values to the internal business service class. If any
formatting, data conversion, or processing is required for the input values, it needs to happen in this method.
In our case it is very simple. We are only mapping the address book number across.
1.

Create the following method in the GetABInfo value object class.

public E1MessageList mapFromPublished (InternalGetABInfo vo) {


E1MessageList messages = new E1MessageList();
//Assign values from the published class to the internal vo object
vo.setMnAddressNumber(new MathNumeric(this.getAddressNumber()));
return messages;
}
2.
3.
4.

Use Alt-Enter as needed to add the necessary import lines.


Notice how the type conversion is being done from integer to the MathNumeric that is used by the
internal value object address number.
Return to the ABInfoTestPub Class. Locate the protected method again. Add the highlighted code.
Right after the internalVO class is instantiated call the mapFromPublished method.

Copyright 2013 by Klee Associates, Inc. www.JDEtips.com

Page 28

Creating a Business Services Wrapper for an


E1 Business Function
//Create a new internal value object.
InternalGetABInfo internalVO = new InternalGetABInfo();
//Copy the values from the published VO and copy to the internal VO
E1MessageList mapMessages = vo.mapFromPublished(internalVO);
//Call BusinessService passing context, connection and internal VO
E1MessageList bssvMessages = ABInfoTest.getABInfoInternal(context,connection,internalVO);
//Add messages returned from BusinessService to message list for PublishedBusinessService.
messages.addMessages (bssvMessages);

Map from Internal Value Object to Published Return Class


After the internal business service class is called we need to return data back to the return value object class
so it can be returned to the calling application.
1.
2.

Locate the new public constructor that we added to the return object class earlier (ReturnABInfo).
Add the code as shown below. Using the accessors, it will copy the values across.

public ReturnABInfo (InternalGetABInfo internalVO) {


//Copy the values from the internal VO to the published return class values.
this.setAddressLine1(internalVO.getSzAddressLine1());
this.setAddressLine2(internalVO.getSzAddressLine2());
this.setCity(internalVO.getSzCity());
this.setState(internalVO.getSzState());
this.setPostalCode(internalVO.getSzZipCodePostal());
this.setNameAlpha(internalVO.getSzNameAlpha());
this.setDateUpdated(internalVO.getJdF0101DateLastUpdated());
this.setTimeLastUpdated(internalVO.getMnF0101TimeLastUpdated());
}
3.

You will notice some code that has underlines indicating compile issues. These exist because of
type conversion issues. We need to create overloaded accessors to handle the type conversions.
Add the following accessors.

Copyright 2013 by Klee Associates, Inc. www.JDEtips.com

Page 29

Creating a Business Services Wrapper for an


E1 Business Function

public void setTimeLastUpdated(MathNumeric timeLastUpdated) {


if (timeLastUpdated != null)
this.timeLastUpdated = new Integer(timeLastUpdated.intValue());
else
this.timeLastUpdated = new Integer (0);
}
public void setDateUpdated(Date dateUpdated) {
Calendar tempCalendar = Calendar.getInstance();
tempCalendar.setTime(dateUpdated);
this.dateUpdated = tempCalendar;
}

4.

Do a Save All

Add the Code to Call the Business Function


1.
2.

Locate the getABInfoInternal method it the ABInfoTest in J550001.


Right click on the blank line after the TODO: call method line. Click on EnterpriseOne on the
pop up menu, select Create Business Function Call.

Copyright 2013 by Klee Associates, Inc. www.JDEtips.com

Page 30

Creating a Business Services Wrapper for an


E1 Business Function

3.
4.

Enter N550001 into object name. Click Find.


Select the GetABInfo function. Click Next.

Copyright 2013 by Klee Associates, Inc. www.JDEtips.com

Page 31

Creating a Business Services Wrapper for an


E1 Business Function

5.

Set the input and outputs as shown. The selection of the check boxes on each item creates the
appropriate code to send data to the BSFN and return data back.

6.

The wizard creates a new method based on your input above. It creates a call to the new method
on the line where you invoked the wizard to call an E1 BSFN. Verify the code looks the same as
below adding code as necessary under the TODO reminder comments. Notice that we added code
to the BSFN call line so we can return messages from the call.

Copyright 2013 by Klee Associates, Inc. www.JDEtips.com

Page 32

Creating a Business Services Wrapper for an


E1 Business Function

7.

You will notice some red underlines indicating a compile issue. When the wizard that created the
new method calls the business function it specifies a generic InputVOType, see below. You need
to fix this to use the actual value object class that is being used. In this case we need to replace
InputVOType with InternalGetABInfo.

8.
9.

At this point, everything should compile.


Fix any compile issues.

Test the Function. Finally!


1.
2.

Select the test class we created, GetABTestClass.


Click on the Run button. You should see output that looks something like this:

Copyright 2013 by Klee Associates, Inc. www.JDEtips.com

Page 33

Creating a Business Services Wrapper for an


E1 Business Function

3.

You can test with other address book numbers by changing this line of code in the test class.
inputVo.setAddressNumber(new Integer (100110));

Check in the Business Service Functions


When checking the business service in, the developer has the opportunity to decide which artifacts should
be included in the check-in. The developer will also specify which class will be a published class. Only the
specified class will be built as a web service on the business services server.
1.
2.

Select JP550001 and click on the Check-In button.


The green check marks indicate which artifacts will be checked in. Clicking on the row header will
check and uncheck the artifact. I always leave them all checked.

Copyright 2013 by Klee Associates, Inc. www.JDEtips.com

Page 34

Creating a Business Services Wrapper for an


E1 Business Function

3.
4.

Select the class that you want to publish. Click on ABInfoTestPub.java.


Click on Row Exit Set Published. This will toggle identifying the class as published or not. It will
then display the selected class in the Published Class Name to confirm which one you selected.

5.
6.

Click on OK to complete the process and check-in the object.


Complete the same steps with J550001. However, you will not select a class to be published.

Scott Beebe has eighteen years of experience in software development, implementation, and
customization, including 14 years of JD Edwards OneWorld/EnterpriseOne Development. Experience

includes software design and development, database design, and customizing and
troubleshooting of J.D. Edwards EnterpriseOne software. Additional J.D. Edwards experience
includes post implementation support, system design and analysis, enhancements, conversions,
modifications, retrofits, implementation, user support and training, technical troubleshooting,
delivered portal components, developed JAVA components to plug into the portal, and systems
management. Scott's website can be viewed here: http://jdetoolsplus.com/

Visit www.JDEtips.com for information on JDEtips University schedule, on-site training and consulting, and
our Journal Document Library.

License Information: The use of JDE is granted to Klee Associates, Inc. by permission from J.D. Edwards World Source Company. The
information on this website and in our publications is the copyrighted work of Klee Associates, Inc. and is owned by Klee Associates, Inc.

Copyright 2013 by Klee Associates, Inc. www.JDEtips.com

Page 35

Creating a Business Services Wrapper for an


E1 Business Function
NO WARRANTY: This documentation is delivered as is, and Klee Associates, Inc. makes no warranty as to its accuracy or use. Any use of
this documentation is at the risk of the user. Although we make every good faith effort to ensure accuracy, this document may include
technical or other inaccuracies or typographical errors. Klee Associates, Inc. reserves the right to make changes without prior notice.
NO AFFILIATION: Klee Associates, Inc. and this publication are not affiliated with or endorsed by J.D. Edwards & Company. J.D. Edwards
software referenced on this site is furnished under license agreements between J.D. Edwards & Company and their customers and can be
used only within the terms of such agreements. J.D. Edwards is a registered trademark of J.D. Edwards & Company. JDE and OneWorld
are registered trademarks of J.D. Edwards World Source Company. WorldSoftware is a trademark of J.D. Edwards World Source
Company. PeopleSoft,the PeopleSoft logo, PeopleTools, PS/inVision, PeopleCode, PeopleBooks, PeopleTalk, and Pure Internet
Architecture are registered trademarks, and Intelligent Context Manager and The Real-Time Enterprise are trademarks of PeopleSoft, Inc.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates.
Klee Associates, Inc. is not affiliated with or endorsed by Oracle Corporation.

Copyright 2013 by Klee Associates, Inc. www.JDEtips.com

Page 36

You might also like