Application management : Tools : Web Services : Developing a Web service client : Referring to other business objects from a web service
Referring to other business objects from a web service
In many use cases for Web services, references need to be made from one business object to other business objects. In Planon ProCenter, support is added for reference fields in Web services.
References to other business objects are in most cases recognizable by the suffix “Ref” in field names, for example, “AddressRef”. Planon ProCenter has several representations of references, of which the largest part consists of integer references. Such an integer always points to the primary key of the referred business object.
For example, if a Person has a reference to working address 25, this actually means that Person refers to the business object Address with primary key 25.
All business objects in Planon ProCenter have a primary key by which they can be uniquely identified. When creating a new, unsaved, business object, the primary key is initially not set. It is assigned as soon as the business object is stored in Planon ProCenter.
A Java-example showing how to set the working address of a person to a newly created address is shown here:
// Create a new address
AddressClientStub addressClient = new AddressClientStub();
Address myAddr = addressClient.create( mySessionId );
// fill values of myAddr with relevant data (not shown)
myAddr.setAddress( “my Address” );
// store the newly created address
myAddr = addressClient.save( mySessionId, myAddr );
// Create a new person whose working address is ‘my Address’
PersonClientStub personClient = new PersonClientStub();
Person myPers = personClient.create( mySessionId );
// fill values of person with relevant data (not shown)
// set the working address of this person to the new address
myPers.setAddressRef( myAddr.getPrimaryKey() );
myPers = personClient.save( mySessionId, myPers );
If you want to link an existing business object, you need to find it first to obtain its primary key. It is common practice to not rely on primary keys as constant values in your code. For example, always search for the address to obtain its primary key, instead of relying on that its primary key is always 25.
You can create a new business object (dependent business object), which has a composite relationship with an existing primary business object (whole business object) using the method > create<USERBOTYPE>part”.
* 
To understand more about Composite Business Objects, see Working with Composite BOs using web services .