uCosminexus Service Platform, Reception and Adapter Definition Guide

[Contents][Glossary][Index][Back][Next]

Appendix F.1 Setup example of HTTP reception (in standard mode)

This section describes an example of setting up an HTTP reception for a business process executed in standard mode.

Organization of this subsection
(1) Overview of setup example
(2) Creating the message formats for the HTTP reception
(3) Adding the HTTP reception
(4) Defining the HTTP reception
(5) Defining the business process
(6) Invoking the HTTP reception

(1) Overview of setup example

This subsection describes the system configuration and flow of processing in this setup example.

The following figure shows an example of the system configuration:

Figure F-1 Configuration of setup example (standard mode)

[Figure]

In this example, the operator uses a Web browser installed on the machine where the HCSC server environment is set up. This example uses a Web server incorporated into the J2EE server. The HTTP reception uses standard mode.

The flow of this setup example is as follows:

  1. The operator uses a GET method to invoke the HTTP reception from the Web browser.
    At this point, he or she sets kilometers per hour and time as parameters of the query string of the HTTP request.
  2. The data transformation definitions in the business process are used to calculate the distance traveled, and the result is set in the body of the response message.
  3. The headers specified in the HTTP Response Header definition file are set and the response is returned to the Web browser.

Header allocated variables are not used in this example. The setup procedure is described below.

(2) Creating the message formats for the HTTP reception

Create the message formats used in the HTTP reception. The message format templates are stored in the following folder:

Copy the entire folder to another location before editing the files it contains. Use the copied files as the basis when creating the message formats.

(a) Creating the request message (body) format

Create the message format to set in body allocated variables in the HTTP reception during reception. Create the message format by editing the template.

Edit the file urecp_http_body_detail_request.xsd.

Note: Do not edit urecp_http_body_request.xsd.

In this example, you add the elements shown in italics which represent kilometers per hour and hours traveled.

HTTP reception header allocated variables are not used in this example.

(b) Creating the response message (body) format

Create the message format to set in body allocated variables in the HTTP reception when providing a response.

The message format below describes processing that returns the distance traveled. Create this format, and save it in the copied folder. The file name is urecp_http_body_response.xsd. Note that there is no template file for the response message (body) format.

(3) Adding the HTTP reception

To add an HTTP reception:

  1. Right-click the Service Definition List in the tree view, and select Add Business Process.
    A business process is added. You do not define the contents of the business process at this stage.
  2. In the Service Definition List in the tree view, right-click the business process you added, and select Add User Defined Reception.
    The Reception Type Selection wizard appears.
  3. Select HTTP Reception as the reception type, and then click Next.
  4. Specify a name for the reception in Reception name.
  5. Click Finish.
    The HTTP reception is added to the business process, and the User-defined Reception Definition window appears.

(4) Defining the HTTP reception

The following shows the information you need to set in the User-defined Reception Definition window. For details on the User-defined Reception Definition window, see 1.2.6 User-Defined Reception Definition Window in the manual Service Platform Reference Guide.

(a) Settings in the User Definition Reception window (basic) window

Enter the settings as shown in the table below.

Table F-1 Settings in the User Definition Reception window (basic) window

Category Item Value to set
User defined reception information Reception name HTTP Reception
Reception ID rcp1
Reception type Custom reception
Default operation name calculateDistance
Operation calculateDistance
Operation information Operation name calculateDistance
Communication model Sync
Request message (Body) Use any type check box Do not use (leave the check box cleared)
Reception Message format urecp_http_body_request.xsd
Service component Use check box Do not use (leave the check box cleared)
Message format --
Data-conversion definition --
Response message (Body) Use any type check box Do not use (leave the check box cleared)
Reception Message format urecp_http_body_response.xsd (the file you created in (2) Creating the message formats for the HTTP reception)
Service component Use check box Do not use (leave the check box cleared)
Message format --
Data-conversion definition --

Legend:
--: Do not set.

(b) Editing the HTTP Response Header definition file

The following describes how to edit the HTTP Response Header definition file. Note that because header allocated variables are not used in the business process in this example, a description of the properties is omitted.

  1. In the Self-defined file area of the User Definition Reception window (detail), select cscurecphttp_header.properties and then click Edit.
    An editor appears in which you can edit the self-defined file.
  2. Amend the content of the HTTP Response Header definition file as follows:
     
    Connection=close
    extension-header=extension-header1
     
    Note: extension-header is set to allow for arbitrary extension headers.
  3. From the Eclipse menu, select File and then Save.
    The HTTP Response Header definition file is saved.
(c) Editing the HTTP reception definition file

The following describes how to edit the HTTP reception definition file.

  1. In the Self-defined file area of the User Definition Reception window (detail), select cscurecphttp.properties and then click Edit.
    An editor appears in which you can edit the self-defined file.
  2. Amend the content of the HTTP reception definition file as follows:
     
    #urecp-http.context-root=
    #urecp-http.max-threads=10
    #urecp-http.exclusive-threads=0
    #urecp-http.queue-size=8192
    #urecp-http.pooled-instance.minimum=0
    #urecp-http.pooled-instance.maximum=0
    #urecp-http.ejb-transaction-timeout=0
    #httprecp.switchover.pass-through.mode=false
    httprecp.http.charset=UTF-8
    httprecp.response.header.filename=cscurecphttp_header.properties
    #httprecp.system-exception.status-code=500
    #httprecp.response.generate.content-length=true
     
    Because the context root (urecp-http.context-root) is omitted in this example, the reception ID of the HTTP reception is used as the default value.
  3. From the Eclipse menu, select File and then Save.
    The HTTP reception definition file is saved.

(5) Defining the business process

The following describes how to define the business process.

(a) Creating the business process

In this example, you create a business process in which a request message passed to an HTTP reception is transformed by a data transformation activity to generate a response message.

Arrange and connect the activities as shown in the following figure:

Figure F-2 Example of business process creation

[Figure]

For details on how to arrange and connect activities, see 5.4 Deploying and Linking Activities in the manual Service Platform Basic Development Guide.

(b) Defining variables

Define the variables used in the business process.

The following table shows the variables to define:

Variable name Description
request_body The request message (body) variable for the HTTP reception
response_body The response message (body) variable for the HTTP reception

Correlation sets are not used in this example.

The definition of these variables takes place in the Take In Message Format dialog box. To define these variables:

  1. Double-click the Variable-Correlation icon on the canvas of the Define Business Process window.
    The List Of Variables And Correlation Sets dialog box appears.

    [Figure]

  2. In Variable name, enter request_body or response_body.
  3. From the Type: drop-down list, select XML.
  4. In the Message format area, click the Take In button.
    The Take In Message Format dialog box appears.
  5. Set the following variables:

    [Figure]

    • request_body
      Category Item Value to set
      Service/Reception Service name --
      Reception name HTTP Reception
      Target for take in Operation name calculateDistance
      Message type Request message (Body)
      Fault name --
      -- Message format request_body
    • response_body
      Category Item Value to set
      Service/Reception Service name --
      Reception name HTTP Reception
      Target for take in Operation name calculateDistance
      Message type Response message (Body)
      Fault name --
      -- Message format response_body

      Legend:
      --: Do not set. Alternatively, there is no corresponding category.

  6. Click OK, and in the List Of Variables And Correlation Sets dialog box, click Add.
    The variable you defined is added.
(c) Defining data transformation

In the data transformation, a perform node operation function (calc1) determines the product of the two parameters in the request message, and maps the resulting value to the response message.

To define this data transformation:

  1. Double-click the data transformation activity on the canvas of the Define Business Process window.
    The Data Transformation Activity dialog box appears.
  2. In the Source Variables area, specify request_body.
  3. In the Destination Variable area, specify response_body.
  4. In the Data TransDefn File field, specify the name you want to give the data transformation definition.

    [Figure]

  5. Click OK.
  6. Double-click the data transformation activity.
    The Select Root Element dialog box appears.
  7. Click OK.
    The Data-conversion definition screen appears.
  8. Select the perform node operation function (calc) from the palette, and place it in the mapping viewer.
  9. Set the mapping lines as shown in the following figure.

    [Figure]

  10. Double-click the perform node operation function.
    The Perform Node Operation dialog box appears.
  11. From the Operation drop-down list, select the operator you want to use (* in this example).

    [Figure]

  12. Click OK.
    This completes the process of defining the data transformation.
(d) Setting up receive and reply activities

The following describes how to set up the receive and reply activities.

Example of setting receive activity
  1. Double-click the receive activity on the canvas of the Define Business Process window.
    The Receive Activity dialog box appears.
  2. Enter the settings as shown below.

    [Figure]

    Item Value to set
    Activity name Receive
    Operation name calculateDistance
    Body allocated variable request_body
    Header allocated variable --
    Correlation set group --
    Communication model Sync
    Instance generation Yes
    Legend:
    --: Do not set.
  3. Click OK.
Example of setting reply activity
  1. Double-click the reply activity on the canvas of the Define Business Process window.
    The Reply Activity dialog box appears.
  2. Enter the settings as shown below.

    [Figure]

    Item Value to set
    Activity name Reply
    Operation name calculateDistance
    Body allocated variable response_body
    Header allocated variable --
    Correlation set group --
    Fault name --
    Legend:
    --: Do not set.
  3. Click OK.

(6) Invoking the HTTP reception

The following describes how to execute the business process you created.

(a) Preparation
  1. From the Eclipse menu, select File and then Save All to save the HCSC component you defined.
  2. From the Windows Start menu, select Cosminexus and then Start Test Server.
  3. Right-click the Service Definition List in the tree view, and select Deploy all services to server and start.
    The repository that includes the business process and the HTTP reception is deployed to the execution environment.
(b) Invoking the HTTP reception

Open your Web browser, and specify the URL below in the address bar. You can change the values in the query string as needed.

 
http://localhost/rcp1/calculateDistance?kilometers_per_hour=80&hours=25
 

The execution results are displayed in the Web browser, as shown in the following figure:

[Figure]