Step 1: Updating the local hosts file
Step 3: Create Web Service Proxy classes using CXF’s wsdl2java tool
Step 4: Create Notification Consumer Service Stubs
Step 9: Publish Notification Consumer Service
Step 10: Subscribe for Notifications – using NotificationProducer Service
3. Running the Sample Application
1.
Introduction
This tutorial is intended to bring you through the first steps involved in creating your 3rd party application using WebServices. This tutorial will show you how to: · Update your local hosts file. · Connect to the splash screen. · Create Web Service Proxy classes using CXF’s wsdl2java tool. · Create Notification Consumer Service Stubs. · Login to the CCT server. We will also provide you with sample code for you to work with.
|
2.
SOA CCT Tutorial using CXF
Description
of Tutorial
This tutorial describes how to utilise the features provided by the SOA CCT Web Services. It demonstrates how a new contact can be created, notifications received, and the state of an agent changed, all through web services. The main procedures in this tutorial are: Step1: Updating the local hosts file Step 3: Create Web Service Proxy classes using CXF’s wsdl2java tool Step 4: Create Notification Consumer service stubs using wsdl2java Step 8: Creating a new Contact Step 9: Publish Notification Consumer Service Step 10: Subscribe for Notifications This tutorial utilises the Session Service and the Notification Producer Service to demonstrate this functionality. Please download the source code here. Notes
about this tutorial
The SOA Web Services must be installed and running on an available server. The tutorial uses eclipse as the IDE and CXF 2.2.5 to publish services. Apache CXF bin directory has been added to the environmental PATH variable. Common programming practices such as delegates, events, threading, and exceptions are left to the individual programmer and are not covered in this tutorial. Exception handling is not shown in the code samples for brevity. You must determine exactly where or how you want to implement the example code shown in these tutorials in your own application. |
Step 1: Updating the local
hosts file
1. Open up the hosts file and map the host name of your server to an IP address |
Step
4: Create Notification Consumer Service Stubs
1. Open a command window. 2. Cd to the project’s autogen.src directory. 3. Run wsdl2java –client command supplying the url to the notification consumer wsdl. 4. Refresh project in eclipse to import generated files.
|
Step
5: Create User API Form
The following user form is used through this tutorial. To continue with this tutorial, you must: [Refer to UserAPIForm.java in project src code] 1. Add the following controls to the design surface. 2. Add Event Handlers 3. Create a button click event handler for the Connect button. Code sample: Connect button click event handler stub
4. Create a button click event handler for the Create button. 5. Create a button click event handler for the Login button.
|
Step
6: Login to CCT Server
[Refer to SessionServiceUtil.java in the source of the sample project] 1. Create a private attribute for the service classes required as shown below. Code sample: Declare service attributes
2. Instantiate the service classes as shown below. Code sample: Instantiating the Service Proxies
3. Set the User Credentials in a Login Request as shown below. Code sample: Create Request to Login to CCT Server
4. Invoke the Login Request & Retrieve Session Token. Code sample: Invoking SessionService – loginToCCTServer request
5. Maintain the ssoToken returned from login : it identifies the users session and a valid SSO token is required for all other service requests.
6. Retrieve terminals associated with the user. Code sample: Get Terminals Request
|
Step
7: Logging in an Agent
[Refer to UserAPIForm.java in the source of the sample project] Code sample: Login Agent Request
|
Step
8: Create a new Contact
[Refer to UserAPIForm.java in the source of the sample project] Code sample: Create a Contact
|
Step
9: Publish Notification Consumer Service
[Refer to SubscribeUtil.java in the source of the sample project] 1. Add a class to implement Notification Consumer Service interface as follows. Code sample: Service Implementer
3. Publish the service class. Code sample: Publish Notification Consumer Service
|
Step
10: Subscribe for Notifications – using NotificationProducer
Service
[Refer to SubscribeUtil.java in the source of the sample project]
1. Define Endpoint Reference Type. This details the notification consumer service endpoint where notifications will be sent to. Code sample: Define a EndpointReferenceType
2. Define Subscription Policy. These attributes are set to true if session related notifications are required. Code sample: Define a subscription policy
3. Define Topic Expression. This details the types of notifications that will be subscribed for. In the example below TerminalConnectionStateListeners are registered for. Code sample: Define a Topic Expression
4. Call the Notification Producer subscribe method. Code sample: Notification Consumer Subscription
|
3.
Running the Sample Application
1. Download the zip file. 2. Open Eclipse. 3. Import an existing project using File – Import option.
4. To set the input, open the Run Dialog & provide the details required (server & user details). 5. Enter in the appropriate details. a. Program arguments: i. Server Name – cs1ktest ii. Open SOA OI CCT port number - 9180 b. VM Arguments i. User Name –Duser=”agent123123” ii. User Password -Dpassword=”password123” iii. Domain -Ddomain=”localhost”
6. Once Project is imported & compiled, Right click on project & select Run As – Java Application.
7. Once Running – validate the Notification Consumer endpoint is running by using a web browser.
8. Click Connect – this attempts to login the user and subscribe for notifications.
9. Enter Agent ID & Click login to login agent.
10. Enter valid destination address & click on Create to create a contact.
|