Saturday, February 9, 2013

Teamcenter SOA : Detail Steps for SOA Creation

This blog provides detail steps of creating your own SOA. The SOA service provides all the query  present in Teamcenter Query Builder. The SOA has one Operation which gat all query object in Teamcenter. The Operation doesn't take any input argument, it return list of Query Objects encapsulated in custom Data Structure.

Detail Steps :
  1. Create a new service library in BMIDE Extensions tab by selecting Project->Code Generation->Services

  1. Select the newly created service library (Ex: D4SoaTest) and create new service
  2. Open the new service (Ex: ServiceTest)
  3. Define the DataTypes and Operations as per the requirement. Ex: Operation is to get all the saved queries. Define Data Types as below
Define data type TestQueryObject

    1. Click on Add button in the Data Types tab
    2. Select Structure and click Next
    3. Enter name as TestObjectQuery and description for it
    4. Select DataType elements by clicking Add button
query->Teamcenter::ImanQuery [holds the query tag]
queryname->std::string [holds the name of the query]
querydescription->std::string [holds the description of the query]

Define data type TestGetSavedQueriesResponse – Used for as return data type in operation which returns vector of query objects holding query tag, name and description

    1. Click on Add button in the Data Types tab
    2. Select Structure and click Next
    3. Enter name as TestGetSavedQueriesResponse and description for it
    4. Select DataType elements by clicking Add button
queries->Vector of TestQueryObject

  1. Create Operation using the above defined data type. Select Operations tab of the service (Ex Test Service). Click Add on to create new operation.
    1. Click on Browse button of New Service Operation dialog
    2. Select D4::Soa::Test::_2012_02::TestService::TestGetSavedQueriesResponse as the return data type
    3. Enter Service Operation Name: testGetSavedQueries
    4. Enter Service Operation Description: SOA Operation for getting Query List
    5. Enter Return Description: List of Query Object in Teamcenter
    6. Click on Finish

  1. Once the Operation is created, in Operation Tab when Service is opened.
  2. Save the datamodel.
  3. Select the library created (D4SoaTest). Select  GenerateCode->Service Artifacts

  1. Check the Console view to know if the code generation is successful or errors in other case.
  2. Source and header files corresponding to each service are created. They are placed in the following path in Navigator view:
Ex: AccentureTest->src->server->D4SoaTest (This folder contains the files which need to be implemented by the developer)
Project->output->client->LibraryName  - This contains the auto generated files for the client (no changes required to these files)
Project->output->server->LibraryName  - This contains the auto generated files for the server(no changes required to these files)
Project->output->types->LibraryName  - This contains the auto generated files for the data types that are created. (no changes required to these files)

  1. Name of the service library:    D4SoaTest
  2. Services in the library D4SoaTest:

  1. TestService

  1. Operations in the service by name TestService:

  1. testGetSavedQueries

  1. Open the source file and enter the required code. Shown below is the file generated in the step #8. Operation ‘testGetSavedQueries’ is high lightened for a quick notice.

  1. Build the project. Dlls are generated in
    1. Project\output\client\jars  (Project\output\types \lib if its c++ bindings) – jars files to added to java client classpath
    2. Project\output\server\lib (libraries which would be copied to Teamcenter Server TC_ROOT\bin)
    3. Project\output\types\jars (Project\output\types\lib if its c++bindings) contains the types definition  – jars files to added to java client classpath

  1. Check console to see a successful build message
  2. libD4soatypes.dll under types\lib and server\lib are same.
  3. Ensure the dependant libraries are added to the library definition. Ex: query module is used in the D4SoaTest library and hence added to the D4SoaTest library definition.

  1. Deploy the data model.  This will deploy the library, service and operation definitions in the template to the database as well as it copies the built server libraries to TC_ROOT\bin. Ex Project\output\server\lib to TC_ROOT\bin

You can now call your SOA at client site in a same way as you called sample SOA. 

Teamcenter SOA : Create You Own SOA

In my last two blog I discussed about basic fundamental of SOA and how to use OOTB SOA in client side. In this blog we will discuss about basic for creating your own SOA. Usually new SOA service is required to be created when you don’t find OOTB SOA satisfying your requirement or what to have the service behavior in different way. Following are the guideline for creating your own SOA.
1)      Check whether you can achieve the required result at client side by using OOTB SOA.
2)      Analyze the desire state of transaction between Client and SOA server layer. For example you have to look whether transaction should be committed in one request or multiple request provide by OOTB SOA is acceptable.
3)      Analyze what service you want to implement. Whether it will be single request base or multiple requests which satisfy the use case.
4)      Analyze what input to perform the service. This will help in defining input data type.
5)      Analyze what output will be provided for requested service and how the output will be used. This will also help in deciding whether you required having loose or strong binding.
Before You Start:
Before start you should understand some aspect of SOA service in teamcenter.
Loose vs. Strong Binding: The binding define how the data map between SOA server and Client.  Loose binding mean Key/Value pair mapping as string map of data and its value. Whereas strong binding means the client data model is populated with typed objects that correspond one-to-one with their server-side object type. Hence decision required to be taken based on use case. For example if SOA service is for creating some static reports then loose Binding can be good option and for integration strong binding is good option.
Data Type:
Data Type defined encapsulation of Data while creating a request for SOA service as well getting output from SOA service.  In SOA you can define data type either of Structure, Map or Enumeration. Meanings of this Data Types are same as in a programming language like C or Java. Structure defines set of basic data types encapsulated in structure. Similarly Map is data container.
Operation defines set of function which will available to client for created a request for services to be performed. The SOA service can be either defined through single operation if it is a simple service or set of Operation if it is a complex use case.
Creating SOA services:
As you understand the basic building block of creating SOA, we are ready for creating your own SOA service in the BMIDE. The detail of steps of creating SOA service is given in this blog. Following are the steps of creating SOA service
1)      Define preference binding. For example for Java you can select loose or strong binding.
2)      Create new SOA service library or use existing if you already have one.
3)      Create new service under SOA service library.
4)      Define all the data type which will be used for SOA Operation.
5)      Defined all the Operations with define data type. The Operation will have input data type and return data types. Data Type can be either defined data type or OOTB data types.
6)      Generate code in BMIDE by selecting Generate Code -> Service Artifacts. This will create stub code for both server and client side (see step blog for detail).
7)      Implement the server side code for all defined operation in BMIDE. The stubs for all Operation is already created by BMIDE and only required to implement the business logic for the Operation.  Server side implementation is always in C++ and ITK API can be used for implementation.
8)      No implementation is required at client side.
9)      Build the BMIDE project. Jar file created for the client (if it is Java Binding) and dll for server.
10)   Deploy the server dll in TC_ROOT\bin directory.
11)   Implement custom SOA service in client side. The process is same as defined for OOTB service in the Blog. Only addition will be to add the client SOA jar file in the Class path for using Java client and client dll if using c++ binding.

The detail steps is given in Steps for creating SOA.
These close my series on Teamcenter SOA. I thanks my friend Bhaskar for introducing me to Teamcenter SOA Framework.
Hope this blogs will help good foundation for all people who want to learn Teamcenter SOA services  and serve as quick start on for using and creating own services.

See Also :