Writing your first BPEL process
Ensure that the Oracle SOA Suite has started (as described in the previously mentioned installation guide) and start JDeveloper. When you start JDeveloper for the first time, it will prompt you for a developer role, as shown in the following screenshot:
JDeveloper has a number of different developer roles that limit the technology choices available to the developer. Choose the Default Role to get access to all JDeveloper functionality. This is needed to access the SOA Suite functionality.
After selecting the role, we are offered a Tip of the Day to tell us about a feature of JDeveloper. After dismissing the Tip of the Day, we are presented with a blank JDeveloper workspace.
The top-left-hand window is the Application Navigator, which lists all the applications that we are working on (it is currently empty as we have not yet defined any). Within JDeveloper, an application is a grouping of one or more related projects. A Project is a collection of related components that make up a deployable resource (for example, an SCA Assembly, Java application, web service, and so on).
Within the context of the SOA Suite, each SCA Assembly is defined within its own project, with an application being a collection of related SCA Assemblies.
On the opposite side of the screen to the Application Navigator tab is the Resource Palette, which contains the My Catalogs tab to hold resources for use in composites and the IDE Connections tab. If we click on this it will list the types of connections we can define to JDeveloper. A connection allows us to define and manage links to external resources such as databases, application servers, and rules engines.
Once defined, we can expand a connection to inspect the content of an external resource, which can then be used to create or edit components that utilize the resource. For example, you can use a database connection to create and configure a database adapter to expose a database table as a web service.
Connections also allow us to deploy projects from JDeveloper to an external resource. If you haven't done so already, then you will need to define a connection to the application server (as described in the installation guide) because we will need this to deploy our SCA Assemblies from within JDeveloper.
The connection to the application server is used to connect to the management interfaces in the target container. We can use it to browse deployed applications, change the status of deployed composites, or as we will do here, deploy new composites to our container.
The main window within JDeveloper is used to edit the artifact that we are currently working on (for example, BPEL Process, XSLT Transformation, Java code, and so on). The top of this window contains a tab for each resource we have open, allowing you to quickly switch between them.
At the moment, the only artifact that we have opened is the Start Page, which provides links to various documents on JDeveloper.
The bottom-left-hand corner contains the Structure window. The content of this depends on the resource we are currently working on.
Within JDeveloper, an application is the main container for our work. It consists of a directory where all our application projects will be created.
So, before we can create our Echo
SCA Assembly, we must create the application to which it will belong. Within the Applications Navigator tab in JDeveloper, click on the New Application… item.
This will launch the Create SOA Application dialog, as shown in the preceding screenshot.
Give the application an appropriate name like SoaSuiteBook11gChapter2.
We can specify the top-level directory in which we want to create our applications. By default, JDeveloper will set it to the following:
Normally, we would specify a directory that's not under JDEVELOPER_HOME
, as this makes it simpler to upgrade to future releases of JDeveloper.
In addition, you can specify an Application Template. For SOA projects, select SOA Application template, and click on the Next button.
Next, JDeveloper will prompt us for the details of a new SOA project.
We provide a name for our project such as EchoComposite and select the technologies we desire to be available in the project. In this case, we leave the default SOA technology selected. The project will be created in a directory that, by default, has the same name as the project and is located under the application directory. These settings can be changed.
Clicking on Next will give us the opportunity to configure our new composite by selecting some initial components. Select Composite With BPEL to create a new Assembly with a BPEL process, as shown in the next screenshot:
SOA project composite templates
We have a number of different templates available to us. Apart from the Empty Composite template, they all populate the composite with an initial component. This may be a BPEL component, a Business Rule component, a Human Task, or a Mediator component. The Composite From Oracle BPA Blueprint is used to import a process from the Oracle BPA Suite and generate it as a BPEL component within the composite.
It is possible to create an Empty Composite and then add the components directly to the composite, so if you choose the wrong template and start working with it, you can always enhance it by adding more components. Even the Empty Composite is not really empty, as it includes all the initial files you need to start building your own composite.
Clicking Finish will launch the Create BPEL Process wizard, as shown in the following screenshot:
Replace the process with a sensible Name like EchoProcess
and select a template of the type Synchronous BPEL Process and click OK. JDeveloper will create a skeleton BPEL Process and a corresponding WSDL that describes the web service implemented by our process. This process will be wrapped in an SCA Assembly.
Note
BPEL process templates cover the different ways in which a client may interact with the process. A Define Service Later template is just the process definition and will be used when we want to have complete control over the types of interfaces the process exposes, we can think of this as an empty BPEL process template. An Asynchronous BPEL Process template is used when we send a one-way message to a process, and then later on we send a one-way message from the process to the caller. This type of interaction is good for processes that run for a long time. A Synchronous BPEL Process is one in which we have a request/reply interaction style. The client sends in a request message and then blocks waiting for the process to provide a reply. This type of interaction is good for processes that need to return an immediate result. A One Way BPEL Process simply receives a one-way input message but no reply is expected. This is useful when we initiate some interaction that will initiate a number of other activities. We may also create a BPEL process that implements a specific interface defined in WSDL by using the Base on a WSDL template. Finally, we may have a BPEL process that is activated when a specific event is generated by the Event Delivery Network (see Chapter 8, Using Business Events) using the Subscribe to Events template.
If we look at the process that JDeveloper has created (as shown in the following screenshot), we can see that in the center is the process itself, which contains the activities to be carried out. At the moment, it just contains an initial activity for receiving a request and a corresponding activity for sending a response.
Either side of the process we have a swim lane containing Partner Links that represent either the caller of our process, as is the case with the echoprocess_client partner links, or services that our BPEL process calls out to. At the moment this is empty as we haven't defined any external references that we use within our BPEL process. Notice also that we don't currently have any content between receiving the call and replying; our process is empty and does nothing.
The Component Palette window (to the right of our process window in the preceding screenshot) lists all the BPEL Activities and Components that we can use within our process. To use any of these, we have to simply drag-and-drop them onto the appropriate place within our process.
If you click on the BPEL Services drop-down, you also have the option of selecting services which we use whenever we need to call out to an external system.
Getting back to our skeleton process, we can see that it consists of two activities; receiveInput and replyOutput. In addition it has two variables, inputVariable
and outputVariable
, which were created as part of our skeleton process.
The first activity is used to receive the initial request from the client invoking our BPEL process; when this request is received it will populate the variable inputVariable
with the content of the request.
The last activity is used to send a response back to the client, and the content of this response will contain the content of outputVariable
.
For the purpose of our simple EchoProcess
we just need to copy the content of the input variable to the output variable.
Assigning values to variables
In BPEL, the <assign>
activity is used to update the values of variables with new data. The <assign>
activity typically consists of one or more copy operations. Each copy consists of a target variable, that is, the variable that you wish to assign a value to and a source, which can either be another variable or an XPath expression.
To insert an Assign activity, drag one from the Component Palette on to our BPEL process at the point just after the receiveInput activity, as shown in the following screenshot:
To configure the Assign activity, double-click on it to open up its configuration window. Click on the green cross to access a menu and select Copy Operation…, as shown in the next screenshot:
This will present us with the Create Copy Operation window, as shown in the following screenshot:
On the left-hand side, we specify the From variable, that is, where we want to copy from. For our process, we want to copy the content of our input variable to our output variable. So expand inputVariable and select /client:process/client:input, as shown in the preceding screenshot.
On the right-hand side, we specify the To variable, that is, where we want to copy to. So expand outputVariable and select /client:processResponse/client:result.
Once you've done this, click OK and then OK again to close the Assign window.
This completes our process, so click on the Save All icon (the fourth icon along, in the top-left-hand corner of JDeveloper) to save our work.
Note
As a BPEL project is made up of multiple files, we typically use Save All to ensure that all modifications are updated at the same time.
Our process is now ready to be deployed. Before doing this, make sure the SOA Suite is running and that within JDeveloper we have defined an Application Server connection (as described in the installation guide).
To deploy the process, right-click on our EchoComposite project and then select Deploy | EchoComposite | to MyApplicationServerConnection.
This will bring up the SOA Deployment Configuration Dialog. This dialog allows us to specify the target servers onto which we wish to deploy the composite. We may also specify a Revision ID for the composite to differentiate it from other deployed versions of the composite. If a revision with the same ID already exists, then it may be replaced by specifying the Overwrite any existing composites with the same revision ID option.
Clicking OK will begin the build and deployment of the composite. JDeveloper will open up a window below our process containing five tabs: Messages, Feedback, BPEL, Deployment, and SOA, to which it outputs the status of the deployment process.
During the build, the SOA tab will indicate if the build was successful, and assuming it was, then an Authorization Request window will pop up requesting credentials for the application server.
On completion of the build process, the Deployment tab should state Successfully deployed archive…., as shown in the following screenshot:
If you don't get this message, then check the log windows for details of the error and fix it accordingly.
Now that our process has been deployed, the next step is to run it. A simple way to do this is to initiate a test instance using the Enterprise Manager (EM) console, which is the web-based management console for SOA Suite.
To access the EM console, open up a browser and enter the following URL:
This will bring up the login screen for the EM console. Log in as weblogic. This will take us to the EM console dashboard, as shown in the following screenshot:
The Dashboard provides us with a summary report on the Fusion Middleware domain. On the left-hand side we have a list of management areas and on the right we have summaries of application deployments, including our EchoComposite under the SOA tab.
From here, click on the composite name, that is, EchoComposite. This will take us to the Dashboard screen for our composite. From here we can see the number of completed and currently executing composite instances.
At the top of the Dashboard there is a Test button that allows us to execute a composite test. Pressing this button brings up the Test Web Service page, as shown in the following screenshot:
When we created our process, JDeveloper automatically created a WSDL file which contained the single operation (that is, process
). However, it's quite common to define processes that have multiple operations, as we will see later on in the book.
The Operation drop-down list allows us to specify which operation we want to invoke. In our case, it's automatically defaulted to process.
When you select the operation to invoke, the console will generate an HTML form with a field for each element in the message payload of the operation (as defined by the WSDL for the process). Here we can enter into each field the value that we want to submit.
For operations with large message payloads it can be simpler to just enter the XML source. If you select the XML View drop-down list the console will replace the form with a free text area with a skeleton XML fragment into which we can insert the required values.
To execute a test instance of our composite, enter some text in the input field and click Test Web Service. This will cause the console to generate a SOAP message and use it to invoke our Echo process.
Upon successful execution of the process, our test page will be updated to show the result which displays the response returned by our process. Here we can see that the result element contains our original input string, as shown in the following screenshot:
If we expand the SOA and soa-infra items on the left-hand side of the page, we will arrive back at the dashboard for the EchoComposite. Clicking on a completed instance will give us a summary of the composite. From here we can see the components that make up our composite. In this case, the composite consists of a single BPEL process.
Clicking on the BPEL process takes us to an audit record of the instance. We can expand the tree view to see details of individual operations like the message sent by replyOutput.
Clicking on the Flow tab will display a graphical representation of the activities within the BPEL process.
Clicking on any of the activities in the audit trail will pop up a window displaying details of the actions performed by that activity. In the following screenshot, we can see details of the message sent by the replyOutput activity:
This completes development of our first BPEL process. The next step is to call it via the Mediator. This will give us the option of transforming the input into the format we desire and of routing to different components based on the input content.
By selecting the composite.xml tab in JDeveloper, we can see the outline of the Assembly that we have created for the BPEL process. We can add a Mediator to this by dragging it from the Component Palette.
Dragging the Mediator Component will cause a dialog to be displayed requesting a Name and Template for the Mediator.
If we select the Define Interface Later template, then we can click OK to add a Mediator to our Assembly. Defining the interface later will allow us to define the interface by wiring it to a service.
Note that the types of interface templates are the same as the ones we saw for our BPEL process.
We want to have the Mediator use the same interface as the BPEL process. To rewire the composite to use a Mediator, we first delete the line joining the EchoProcess in the Exposed Services swimlane to the BPEL process by right-clicking on the line and selecting Delete.
We
can now wire the EchoProcess service to the input of the Mediator by clicking on the chevron in the top-right corner of the exposed service and dragging it onto the connection point on the left-hand side of the Mediator.
Now wire the Mediator to the BPEL process by dragging the yellow arrow on the Mediator onto the blue chevron on the BPEL process.
We have now configured the Mediator to accept the same interface as the BPEL process and wired the Mediator to forward all messages onto the BPEL process. The default behavior of the Mediator, if it has no explicit rules, is to route the input request to the outbound request and then route the response, if any, from the target to the client.
We
can now deploy and test the Assembly containing the Mediator in the same way that we deployed and tested the Assembly containing the BPEL process.
In preparation for this, we will need the URL for the WSDL of our process. To obtain this, from the EM Dashboard, click on the EchoComposite Assembly, and then the connector icon to the right of the Settings button. This will display a link for the WSDL location and Endpoint, as shown in the following screenshot:
If you click on this link, the EM console will open a window showing details of the WSDL. Make a note of the WSDL location as we will need this in a moment.
Within JDeveloper, an application is the main container for our work. It consists of a directory where all our application projects will be created.
So, before we can create our Echo
SCA Assembly, we must create the application to which it will belong. Within the Applications Navigator tab in JDeveloper, click on the New Application… item.
This will launch the Create SOA Application dialog, as shown in the preceding screenshot.
Give the application an appropriate name like SoaSuiteBook11gChapter2.
We can specify the top-level directory in which we want to create our applications. By default, JDeveloper will set it to the following:
Normally, we would specify a directory that's not under JDEVELOPER_HOME
, as this makes it simpler to upgrade to future releases of JDeveloper.
In addition, you can specify an Application Template. For SOA projects, select SOA Application template, and click on the Next button.
Next, JDeveloper will prompt us for the details of a new SOA project.
We provide a name for our project such as EchoComposite and select the technologies we desire to be available in the project. In this case, we leave the default SOA technology selected. The project will be created in a directory that, by default, has the same name as the project and is located under the application directory. These settings can be changed.
Clicking on Next will give us the opportunity to configure our new composite by selecting some initial components. Select Composite With BPEL to create a new Assembly with a BPEL process, as shown in the next screenshot:
SOA project composite templates
We have a number of different templates available to us. Apart from the Empty Composite template, they all populate the composite with an initial component. This may be a BPEL component, a Business Rule component, a Human Task, or a Mediator component. The Composite From Oracle BPA Blueprint is used to import a process from the Oracle BPA Suite and generate it as a BPEL component within the composite.
It is possible to create an Empty Composite and then add the components directly to the composite, so if you choose the wrong template and start working with it, you can always enhance it by adding more components. Even the Empty Composite is not really empty, as it includes all the initial files you need to start building your own composite.
Clicking Finish will launch the Create BPEL Process wizard, as shown in the following screenshot:
Replace the process with a sensible Name like EchoProcess
and select a template of the type Synchronous BPEL Process and click OK. JDeveloper will create a skeleton BPEL Process and a corresponding WSDL that describes the web service implemented by our process. This process will be wrapped in an SCA Assembly.
Note
BPEL process templates cover the different ways in which a client may interact with the process. A Define Service Later template is just the process definition and will be used when we want to have complete control over the types of interfaces the process exposes, we can think of this as an empty BPEL process template. An Asynchronous BPEL Process template is used when we send a one-way message to a process, and then later on we send a one-way message from the process to the caller. This type of interaction is good for processes that run for a long time. A Synchronous BPEL Process is one in which we have a request/reply interaction style. The client sends in a request message and then blocks waiting for the process to provide a reply. This type of interaction is good for processes that need to return an immediate result. A One Way BPEL Process simply receives a one-way input message but no reply is expected. This is useful when we initiate some interaction that will initiate a number of other activities. We may also create a BPEL process that implements a specific interface defined in WSDL by using the Base on a WSDL template. Finally, we may have a BPEL process that is activated when a specific event is generated by the Event Delivery Network (see Chapter 8, Using Business Events) using the Subscribe to Events template.
If we look at the process that JDeveloper has created (as shown in the following screenshot), we can see that in the center is the process itself, which contains the activities to be carried out. At the moment, it just contains an initial activity for receiving a request and a corresponding activity for sending a response.
Either side of the process we have a swim lane containing Partner Links that represent either the caller of our process, as is the case with the echoprocess_client partner links, or services that our BPEL process calls out to. At the moment this is empty as we haven't defined any external references that we use within our BPEL process. Notice also that we don't currently have any content between receiving the call and replying; our process is empty and does nothing.
The Component Palette window (to the right of our process window in the preceding screenshot) lists all the BPEL Activities and Components that we can use within our process. To use any of these, we have to simply drag-and-drop them onto the appropriate place within our process.
If you click on the BPEL Services drop-down, you also have the option of selecting services which we use whenever we need to call out to an external system.
Getting back to our skeleton process, we can see that it consists of two activities; receiveInput and replyOutput. In addition it has two variables, inputVariable
and outputVariable
, which were created as part of our skeleton process.
The first activity is used to receive the initial request from the client invoking our BPEL process; when this request is received it will populate the variable inputVariable
with the content of the request.
The last activity is used to send a response back to the client, and the content of this response will contain the content of outputVariable
.
For the purpose of our simple EchoProcess
we just need to copy the content of the input variable to the output variable.
Assigning values to variables
In BPEL, the <assign>
activity is used to update the values of variables with new data. The <assign>
activity typically consists of one or more copy operations. Each copy consists of a target variable, that is, the variable that you wish to assign a value to and a source, which can either be another variable or an XPath expression.
To insert an Assign activity, drag one from the Component Palette on to our BPEL process at the point just after the receiveInput activity, as shown in the following screenshot:
To configure the Assign activity, double-click on it to open up its configuration window. Click on the green cross to access a menu and select Copy Operation…, as shown in the next screenshot:
This will present us with the Create Copy Operation window, as shown in the following screenshot:
On the left-hand side, we specify the From variable, that is, where we want to copy from. For our process, we want to copy the content of our input variable to our output variable. So expand inputVariable and select /client:process/client:input, as shown in the preceding screenshot.
On the right-hand side, we specify the To variable, that is, where we want to copy to. So expand outputVariable and select /client:processResponse/client:result.
Once you've done this, click OK and then OK again to close the Assign window.
This completes our process, so click on the Save All icon (the fourth icon along, in the top-left-hand corner of JDeveloper) to save our work.
Note
As a BPEL project is made up of multiple files, we typically use Save All to ensure that all modifications are updated at the same time.
Our process is now ready to be deployed. Before doing this, make sure the SOA Suite is running and that within JDeveloper we have defined an Application Server connection (as described in the installation guide).
To deploy the process, right-click on our EchoComposite project and then select Deploy | EchoComposite | to MyApplicationServerConnection.
This will bring up the SOA Deployment Configuration Dialog. This dialog allows us to specify the target servers onto which we wish to deploy the composite. We may also specify a Revision ID for the composite to differentiate it from other deployed versions of the composite. If a revision with the same ID already exists, then it may be replaced by specifying the Overwrite any existing composites with the same revision ID option.
Clicking OK will begin the build and deployment of the composite. JDeveloper will open up a window below our process containing five tabs: Messages, Feedback, BPEL, Deployment, and SOA, to which it outputs the status of the deployment process.
During the build, the SOA tab will indicate if the build was successful, and assuming it was, then an Authorization Request window will pop up requesting credentials for the application server.
On completion of the build process, the Deployment tab should state Successfully deployed archive…., as shown in the following screenshot:
If you don't get this message, then check the log windows for details of the error and fix it accordingly.
Now that our process has been deployed, the next step is to run it. A simple way to do this is to initiate a test instance using the Enterprise Manager (EM) console, which is the web-based management console for SOA Suite.
To access the EM console, open up a browser and enter the following URL:
This will bring up the login screen for the EM console. Log in as weblogic. This will take us to the EM console dashboard, as shown in the following screenshot:
The Dashboard provides us with a summary report on the Fusion Middleware domain. On the left-hand side we have a list of management areas and on the right we have summaries of application deployments, including our EchoComposite under the SOA tab.
From here, click on the composite name, that is, EchoComposite. This will take us to the Dashboard screen for our composite. From here we can see the number of completed and currently executing composite instances.
At the top of the Dashboard there is a Test button that allows us to execute a composite test. Pressing this button brings up the Test Web Service page, as shown in the following screenshot:
When we created our process, JDeveloper automatically created a WSDL file which contained the single operation (that is, process
). However, it's quite common to define processes that have multiple operations, as we will see later on in the book.
The Operation drop-down list allows us to specify which operation we want to invoke. In our case, it's automatically defaulted to process.
When you select the operation to invoke, the console will generate an HTML form with a field for each element in the message payload of the operation (as defined by the WSDL for the process). Here we can enter into each field the value that we want to submit.
For operations with large message payloads it can be simpler to just enter the XML source. If you select the XML View drop-down list the console will replace the form with a free text area with a skeleton XML fragment into which we can insert the required values.
To execute a test instance of our composite, enter some text in the input field and click Test Web Service. This will cause the console to generate a SOAP message and use it to invoke our Echo process.
Upon successful execution of the process, our test page will be updated to show the result which displays the response returned by our process. Here we can see that the result element contains our original input string, as shown in the following screenshot:
If we expand the SOA and soa-infra items on the left-hand side of the page, we will arrive back at the dashboard for the EchoComposite. Clicking on a completed instance will give us a summary of the composite. From here we can see the components that make up our composite. In this case, the composite consists of a single BPEL process.
Clicking on the BPEL process takes us to an audit record of the instance. We can expand the tree view to see details of individual operations like the message sent by replyOutput.
Clicking on the Flow tab will display a graphical representation of the activities within the BPEL process.
Clicking on any of the activities in the audit trail will pop up a window displaying details of the actions performed by that activity. In the following screenshot, we can see details of the message sent by the replyOutput activity:
This completes development of our first BPEL process. The next step is to call it via the Mediator. This will give us the option of transforming the input into the format we desire and of routing to different components based on the input content.
By selecting the composite.xml tab in JDeveloper, we can see the outline of the Assembly that we have created for the BPEL process. We can add a Mediator to this by dragging it from the Component Palette.
Dragging the Mediator Component will cause a dialog to be displayed requesting a Name and Template for the Mediator.
If we select the Define Interface Later template, then we can click OK to add a Mediator to our Assembly. Defining the interface later will allow us to define the interface by wiring it to a service.
Note that the types of interface templates are the same as the ones we saw for our BPEL process.
We want to have the Mediator use the same interface as the BPEL process. To rewire the composite to use a Mediator, we first delete the line joining the EchoProcess in the Exposed Services swimlane to the BPEL process by right-clicking on the line and selecting Delete.
We
can now wire the EchoProcess service to the input of the Mediator by clicking on the chevron in the top-right corner of the exposed service and dragging it onto the connection point on the left-hand side of the Mediator.
Now wire the Mediator to the BPEL process by dragging the yellow arrow on the Mediator onto the blue chevron on the BPEL process.
We have now configured the Mediator to accept the same interface as the BPEL process and wired the Mediator to forward all messages onto the BPEL process. The default behavior of the Mediator, if it has no explicit rules, is to route the input request to the outbound request and then route the response, if any, from the target to the client.
We
can now deploy and test the Assembly containing the Mediator in the same way that we deployed and tested the Assembly containing the BPEL process.
In preparation for this, we will need the URL for the WSDL of our process. To obtain this, from the EM Dashboard, click on the EchoComposite Assembly, and then the connector icon to the right of the Settings button. This will display a link for the WSDL location and Endpoint, as shown in the following screenshot:
If you click on this link, the EM console will open a window showing details of the WSDL. Make a note of the WSDL location as we will need this in a moment.
We provide a name for our project such as EchoComposite and select the technologies we desire to be available in the project. In this case, we leave the default SOA technology selected. The project will be created in a directory that, by default, has the same name as the project and is located under the application directory. These settings can be changed.
Clicking on Next will give us the opportunity to configure our new composite by selecting some initial components. Select Composite With BPEL to create a new Assembly with a BPEL process, as shown in the next screenshot:
SOA project composite templates
We have a number of different templates available to us. Apart from the Empty Composite template, they all populate the composite with an initial component. This may be a BPEL component, a Business Rule component, a Human Task, or a Mediator component. The Composite From Oracle BPA Blueprint is used to import a process from the Oracle BPA Suite and generate it as a BPEL component within the composite.
It is possible to create an Empty Composite and then add the components directly to the composite, so if you choose the wrong template and start working with it, you can always enhance it by adding more components. Even the Empty Composite is not really empty, as it includes all the initial files you need to start building your own composite.
Clicking Finish will launch the Create BPEL Process wizard, as shown in the following screenshot:
Replace the process with a sensible Name like EchoProcess
and select a template of the type Synchronous BPEL Process and click OK. JDeveloper will create a skeleton BPEL Process and a corresponding WSDL that describes the web service implemented by our process. This process will be wrapped in an SCA Assembly.
Note
BPEL process templates cover the different ways in which a client may interact with the process. A Define Service Later template is just the process definition and will be used when we want to have complete control over the types of interfaces the process exposes, we can think of this as an empty BPEL process template. An Asynchronous BPEL Process template is used when we send a one-way message to a process, and then later on we send a one-way message from the process to the caller. This type of interaction is good for processes that run for a long time. A Synchronous BPEL Process is one in which we have a request/reply interaction style. The client sends in a request message and then blocks waiting for the process to provide a reply. This type of interaction is good for processes that need to return an immediate result. A One Way BPEL Process simply receives a one-way input message but no reply is expected. This is useful when we initiate some interaction that will initiate a number of other activities. We may also create a BPEL process that implements a specific interface defined in WSDL by using the Base on a WSDL template. Finally, we may have a BPEL process that is activated when a specific event is generated by the Event Delivery Network (see Chapter 8, Using Business Events) using the Subscribe to Events template.
If we look at the process that JDeveloper has created (as shown in the following screenshot), we can see that in the center is the process itself, which contains the activities to be carried out. At the moment, it just contains an initial activity for receiving a request and a corresponding activity for sending a response.
Either side of the process we have a swim lane containing Partner Links that represent either the caller of our process, as is the case with the echoprocess_client partner links, or services that our BPEL process calls out to. At the moment this is empty as we haven't defined any external references that we use within our BPEL process. Notice also that we don't currently have any content between receiving the call and replying; our process is empty and does nothing.
The Component Palette window (to the right of our process window in the preceding screenshot) lists all the BPEL Activities and Components that we can use within our process. To use any of these, we have to simply drag-and-drop them onto the appropriate place within our process.
If you click on the BPEL Services drop-down, you also have the option of selecting services which we use whenever we need to call out to an external system.
Getting back to our skeleton process, we can see that it consists of two activities; receiveInput and replyOutput. In addition it has two variables, inputVariable
and outputVariable
, which were created as part of our skeleton process.
The first activity is used to receive the initial request from the client invoking our BPEL process; when this request is received it will populate the variable inputVariable
with the content of the request.
The last activity is used to send a response back to the client, and the content of this response will contain the content of outputVariable
.
For the purpose of our simple EchoProcess
we just need to copy the content of the input variable to the output variable.
Assigning values to variables
In BPEL, the <assign>
activity is used to update the values of variables with new data. The <assign>
activity typically consists of one or more copy operations. Each copy consists of a target variable, that is, the variable that you wish to assign a value to and a source, which can either be another variable or an XPath expression.
To insert an Assign activity, drag one from the Component Palette on to our BPEL process at the point just after the receiveInput activity, as shown in the following screenshot:
To configure the Assign activity, double-click on it to open up its configuration window. Click on the green cross to access a menu and select Copy Operation…, as shown in the next screenshot:
This will present us with the Create Copy Operation window, as shown in the following screenshot:
On the left-hand side, we specify the From variable, that is, where we want to copy from. For our process, we want to copy the content of our input variable to our output variable. So expand inputVariable and select /client:process/client:input, as shown in the preceding screenshot.
On the right-hand side, we specify the To variable, that is, where we want to copy to. So expand outputVariable and select /client:processResponse/client:result.
Once you've done this, click OK and then OK again to close the Assign window.
This completes our process, so click on the Save All icon (the fourth icon along, in the top-left-hand corner of JDeveloper) to save our work.
Note
As a BPEL project is made up of multiple files, we typically use Save All to ensure that all modifications are updated at the same time.
Our process is now ready to be deployed. Before doing this, make sure the SOA Suite is running and that within JDeveloper we have defined an Application Server connection (as described in the installation guide).
To deploy the process, right-click on our EchoComposite project and then select Deploy | EchoComposite | to MyApplicationServerConnection.
This will bring up the SOA Deployment Configuration Dialog. This dialog allows us to specify the target servers onto which we wish to deploy the composite. We may also specify a Revision ID for the composite to differentiate it from other deployed versions of the composite. If a revision with the same ID already exists, then it may be replaced by specifying the Overwrite any existing composites with the same revision ID option.
Clicking OK will begin the build and deployment of the composite. JDeveloper will open up a window below our process containing five tabs: Messages, Feedback, BPEL, Deployment, and SOA, to which it outputs the status of the deployment process.
During the build, the SOA tab will indicate if the build was successful, and assuming it was, then an Authorization Request window will pop up requesting credentials for the application server.
On completion of the build process, the Deployment tab should state Successfully deployed archive…., as shown in the following screenshot:
If you don't get this message, then check the log windows for details of the error and fix it accordingly.
Now that our process has been deployed, the next step is to run it. A simple way to do this is to initiate a test instance using the Enterprise Manager (EM) console, which is the web-based management console for SOA Suite.
To access the EM console, open up a browser and enter the following URL:
This will bring up the login screen for the EM console. Log in as weblogic. This will take us to the EM console dashboard, as shown in the following screenshot:
The Dashboard provides us with a summary report on the Fusion Middleware domain. On the left-hand side we have a list of management areas and on the right we have summaries of application deployments, including our EchoComposite under the SOA tab.
From here, click on the composite name, that is, EchoComposite. This will take us to the Dashboard screen for our composite. From here we can see the number of completed and currently executing composite instances.
At the top of the Dashboard there is a Test button that allows us to execute a composite test. Pressing this button brings up the Test Web Service page, as shown in the following screenshot:
When we created our process, JDeveloper automatically created a WSDL file which contained the single operation (that is, process
). However, it's quite common to define processes that have multiple operations, as we will see later on in the book.
The Operation drop-down list allows us to specify which operation we want to invoke. In our case, it's automatically defaulted to process.
When you select the operation to invoke, the console will generate an HTML form with a field for each element in the message payload of the operation (as defined by the WSDL for the process). Here we can enter into each field the value that we want to submit.
For operations with large message payloads it can be simpler to just enter the XML source. If you select the XML View drop-down list the console will replace the form with a free text area with a skeleton XML fragment into which we can insert the required values.
To execute a test instance of our composite, enter some text in the input field and click Test Web Service. This will cause the console to generate a SOAP message and use it to invoke our Echo process.
Upon successful execution of the process, our test page will be updated to show the result which displays the response returned by our process. Here we can see that the result element contains our original input string, as shown in the following screenshot:
If we expand the SOA and soa-infra items on the left-hand side of the page, we will arrive back at the dashboard for the EchoComposite. Clicking on a completed instance will give us a summary of the composite. From here we can see the components that make up our composite. In this case, the composite consists of a single BPEL process.
Clicking on the BPEL process takes us to an audit record of the instance. We can expand the tree view to see details of individual operations like the message sent by replyOutput.
Clicking on the Flow tab will display a graphical representation of the activities within the BPEL process.
Clicking on any of the activities in the audit trail will pop up a window displaying details of the actions performed by that activity. In the following screenshot, we can see details of the message sent by the replyOutput activity:
This completes development of our first BPEL process. The next step is to call it via the Mediator. This will give us the option of transforming the input into the format we desire and of routing to different components based on the input content.
By selecting the composite.xml tab in JDeveloper, we can see the outline of the Assembly that we have created for the BPEL process. We can add a Mediator to this by dragging it from the Component Palette.
Dragging the Mediator Component will cause a dialog to be displayed requesting a Name and Template for the Mediator.
If we select the Define Interface Later template, then we can click OK to add a Mediator to our Assembly. Defining the interface later will allow us to define the interface by wiring it to a service.
Note that the types of interface templates are the same as the ones we saw for our BPEL process.
We want to have the Mediator use the same interface as the BPEL process. To rewire the composite to use a Mediator, we first delete the line joining the EchoProcess in the Exposed Services swimlane to the BPEL process by right-clicking on the line and selecting Delete.
We
can now wire the EchoProcess service to the input of the Mediator by clicking on the chevron in the top-right corner of the exposed service and dragging it onto the connection point on the left-hand side of the Mediator.
Now wire the Mediator to the BPEL process by dragging the yellow arrow on the Mediator onto the blue chevron on the BPEL process.
We have now configured the Mediator to accept the same interface as the BPEL process and wired the Mediator to forward all messages onto the BPEL process. The default behavior of the Mediator, if it has no explicit rules, is to route the input request to the outbound request and then route the response, if any, from the target to the client.
We
can now deploy and test the Assembly containing the Mediator in the same way that we deployed and tested the Assembly containing the BPEL process.
In preparation for this, we will need the URL for the WSDL of our process. To obtain this, from the EM Dashboard, click on the EchoComposite Assembly, and then the connector icon to the right of the Settings button. This will display a link for the WSDL location and Endpoint, as shown in the following screenshot:
If you click on this link, the EM console will open a window showing details of the WSDL. Make a note of the WSDL location as we will need this in a moment.
SOA project composite templates
We have a number of different templates available to us. Apart from the Empty Composite template, they all populate the composite with an initial component. This may be a BPEL component, a Business Rule component, a Human Task, or a Mediator component. The Composite From Oracle BPA Blueprint is used to import a process from the Oracle BPA Suite and generate it as a BPEL component within the composite.
It is possible to create an Empty Composite and then add the components directly to the composite, so if you choose the wrong template and start working with it, you can always enhance it by adding more components. Even the Empty Composite is not really empty, as it includes all the initial files you need to start building your own composite.
Clicking Finish will launch the Create BPEL Process wizard, as shown in the following screenshot:
Replace the process with a sensible Name like EchoProcess
and select a template of the type Synchronous BPEL Process and click OK. JDeveloper will create a skeleton BPEL Process and a corresponding WSDL that describes the web service implemented by our process. This process will be wrapped in an SCA Assembly.
Note
BPEL process templates cover the different ways in which a client may interact with the process. A Define Service Later template is just the process definition and will be used when we want to have complete control over the types of interfaces the process exposes, we can think of this as an empty BPEL process template. An Asynchronous BPEL Process template is used when we send a one-way message to a process, and then later on we send a one-way message from the process to the caller. This type of interaction is good for processes that run for a long time. A Synchronous BPEL Process is one in which we have a request/reply interaction style. The client sends in a request message and then blocks waiting for the process to provide a reply. This type of interaction is good for processes that need to return an immediate result. A One Way BPEL Process simply receives a one-way input message but no reply is expected. This is useful when we initiate some interaction that will initiate a number of other activities. We may also create a BPEL process that implements a specific interface defined in WSDL by using the Base on a WSDL template. Finally, we may have a BPEL process that is activated when a specific event is generated by the Event Delivery Network (see Chapter 8, Using Business Events) using the Subscribe to Events template.
If we look at the process that JDeveloper has created (as shown in the following screenshot), we can see that in the center is the process itself, which contains the activities to be carried out. At the moment, it just contains an initial activity for receiving a request and a corresponding activity for sending a response.
Either side of the process we have a swim lane containing Partner Links that represent either the caller of our process, as is the case with the echoprocess_client partner links, or services that our BPEL process calls out to. At the moment this is empty as we haven't defined any external references that we use within our BPEL process. Notice also that we don't currently have any content between receiving the call and replying; our process is empty and does nothing.
The Component Palette window (to the right of our process window in the preceding screenshot) lists all the BPEL Activities and Components that we can use within our process. To use any of these, we have to simply drag-and-drop them onto the appropriate place within our process.
If you click on the BPEL Services drop-down, you also have the option of selecting services which we use whenever we need to call out to an external system.
Getting back to our skeleton process, we can see that it consists of two activities; receiveInput and replyOutput. In addition it has two variables, inputVariable
and outputVariable
, which were created as part of our skeleton process.
The first activity is used to receive the initial request from the client invoking our BPEL process; when this request is received it will populate the variable inputVariable
with the content of the request.
The last activity is used to send a response back to the client, and the content of this response will contain the content of outputVariable
.
For the purpose of our simple EchoProcess
we just need to copy the content of the input variable to the output variable.
Assigning values to variables
In BPEL, the <assign>
activity is used to update the values of variables with new data. The <assign>
activity typically consists of one or more copy operations. Each copy consists of a target variable, that is, the variable that you wish to assign a value to and a source, which can either be another variable or an XPath expression.
To insert an Assign activity, drag one from the Component Palette on to our BPEL process at the point just after the receiveInput activity, as shown in the following screenshot:
To configure the Assign activity, double-click on it to open up its configuration window. Click on the green cross to access a menu and select Copy Operation…, as shown in the next screenshot:
This will present us with the Create Copy Operation window, as shown in the following screenshot:
On the left-hand side, we specify the From variable, that is, where we want to copy from. For our process, we want to copy the content of our input variable to our output variable. So expand inputVariable and select /client:process/client:input, as shown in the preceding screenshot.
On the right-hand side, we specify the To variable, that is, where we want to copy to. So expand outputVariable and select /client:processResponse/client:result.
Once you've done this, click OK and then OK again to close the Assign window.
This completes our process, so click on the Save All icon (the fourth icon along, in the top-left-hand corner of JDeveloper) to save our work.
Note
As a BPEL project is made up of multiple files, we typically use Save All to ensure that all modifications are updated at the same time.
Our process is now ready to be deployed. Before doing this, make sure the SOA Suite is running and that within JDeveloper we have defined an Application Server connection (as described in the installation guide).
To deploy the process, right-click on our EchoComposite project and then select Deploy | EchoComposite | to MyApplicationServerConnection.
This will bring up the SOA Deployment Configuration Dialog. This dialog allows us to specify the target servers onto which we wish to deploy the composite. We may also specify a Revision ID for the composite to differentiate it from other deployed versions of the composite. If a revision with the same ID already exists, then it may be replaced by specifying the Overwrite any existing composites with the same revision ID option.
Clicking OK will begin the build and deployment of the composite. JDeveloper will open up a window below our process containing five tabs: Messages, Feedback, BPEL, Deployment, and SOA, to which it outputs the status of the deployment process.
During the build, the SOA tab will indicate if the build was successful, and assuming it was, then an Authorization Request window will pop up requesting credentials for the application server.
On completion of the build process, the Deployment tab should state Successfully deployed archive…., as shown in the following screenshot:
If you don't get this message, then check the log windows for details of the error and fix it accordingly.
Now that our process has been deployed, the next step is to run it. A simple way to do this is to initiate a test instance using the Enterprise Manager (EM) console, which is the web-based management console for SOA Suite.
To access the EM console, open up a browser and enter the following URL:
This will bring up the login screen for the EM console. Log in as weblogic. This will take us to the EM console dashboard, as shown in the following screenshot:
The Dashboard provides us with a summary report on the Fusion Middleware domain. On the left-hand side we have a list of management areas and on the right we have summaries of application deployments, including our EchoComposite under the SOA tab.
From here, click on the composite name, that is, EchoComposite. This will take us to the Dashboard screen for our composite. From here we can see the number of completed and currently executing composite instances.
At the top of the Dashboard there is a Test button that allows us to execute a composite test. Pressing this button brings up the Test Web Service page, as shown in the following screenshot:
When we created our process, JDeveloper automatically created a WSDL file which contained the single operation (that is, process
). However, it's quite common to define processes that have multiple operations, as we will see later on in the book.
The Operation drop-down list allows us to specify which operation we want to invoke. In our case, it's automatically defaulted to process.
When you select the operation to invoke, the console will generate an HTML form with a field for each element in the message payload of the operation (as defined by the WSDL for the process). Here we can enter into each field the value that we want to submit.
For operations with large message payloads it can be simpler to just enter the XML source. If you select the XML View drop-down list the console will replace the form with a free text area with a skeleton XML fragment into which we can insert the required values.
To execute a test instance of our composite, enter some text in the input field and click Test Web Service. This will cause the console to generate a SOAP message and use it to invoke our Echo process.
Upon successful execution of the process, our test page will be updated to show the result which displays the response returned by our process. Here we can see that the result element contains our original input string, as shown in the following screenshot:
If we expand the SOA and soa-infra items on the left-hand side of the page, we will arrive back at the dashboard for the EchoComposite. Clicking on a completed instance will give us a summary of the composite. From here we can see the components that make up our composite. In this case, the composite consists of a single BPEL process.
Clicking on the BPEL process takes us to an audit record of the instance. We can expand the tree view to see details of individual operations like the message sent by replyOutput.
Clicking on the Flow tab will display a graphical representation of the activities within the BPEL process.
Clicking on any of the activities in the audit trail will pop up a window displaying details of the actions performed by that activity. In the following screenshot, we can see details of the message sent by the replyOutput activity:
This completes development of our first BPEL process. The next step is to call it via the Mediator. This will give us the option of transforming the input into the format we desire and of routing to different components based on the input content.
By selecting the composite.xml tab in JDeveloper, we can see the outline of the Assembly that we have created for the BPEL process. We can add a Mediator to this by dragging it from the Component Palette.
Dragging the Mediator Component will cause a dialog to be displayed requesting a Name and Template for the Mediator.
If we select the Define Interface Later template, then we can click OK to add a Mediator to our Assembly. Defining the interface later will allow us to define the interface by wiring it to a service.
Note that the types of interface templates are the same as the ones we saw for our BPEL process.
We want to have the Mediator use the same interface as the BPEL process. To rewire the composite to use a Mediator, we first delete the line joining the EchoProcess in the Exposed Services swimlane to the BPEL process by right-clicking on the line and selecting Delete.
We
can now wire the EchoProcess service to the input of the Mediator by clicking on the chevron in the top-right corner of the exposed service and dragging it onto the connection point on the left-hand side of the Mediator.
Now wire the Mediator to the BPEL process by dragging the yellow arrow on the Mediator onto the blue chevron on the BPEL process.
We have now configured the Mediator to accept the same interface as the BPEL process and wired the Mediator to forward all messages onto the BPEL process. The default behavior of the Mediator, if it has no explicit rules, is to route the input request to the outbound request and then route the response, if any, from the target to the client.
We
can now deploy and test the Assembly containing the Mediator in the same way that we deployed and tested the Assembly containing the BPEL process.
In preparation for this, we will need the URL for the WSDL of our process. To obtain this, from the EM Dashboard, click on the EchoComposite Assembly, and then the connector icon to the right of the Settings button. This will display a link for the WSDL location and Endpoint, as shown in the following screenshot:
If you click on this link, the EM console will open a window showing details of the WSDL. Make a note of the WSDL location as we will need this in a moment.
Clicking Finish will launch the Create BPEL Process wizard, as shown in the following screenshot:
Replace the process with a sensible Name like EchoProcess
and select a template of the type Synchronous BPEL Process and click OK. JDeveloper will create a skeleton BPEL Process and a corresponding WSDL that describes the web service implemented by our process. This process will be wrapped in an SCA Assembly.
Note
BPEL process templates cover the different ways in which a client may interact with the process. A Define Service Later template is just the process definition and will be used when we want to have complete control over the types of interfaces the process exposes, we can think of this as an empty BPEL process template. An Asynchronous BPEL Process template is used when we send a one-way message to a process, and then later on we send a one-way message from the process to the caller. This type of interaction is good for processes that run for a long time. A Synchronous BPEL Process is one in which we have a request/reply interaction style. The client sends in a request message and then blocks waiting for the process to provide a reply. This type of interaction is good for processes that need to return an immediate result. A One Way BPEL Process simply receives a one-way input message but no reply is expected. This is useful when we initiate some interaction that will initiate a number of other activities. We may also create a BPEL process that implements a specific interface defined in WSDL by using the Base on a WSDL template. Finally, we may have a BPEL process that is activated when a specific event is generated by the Event Delivery Network (see Chapter 8, Using Business Events) using the Subscribe to Events template.
If we look at the process that JDeveloper has created (as shown in the following screenshot), we can see that in the center is the process itself, which contains the activities to be carried out. At the moment, it just contains an initial activity for receiving a request and a corresponding activity for sending a response.
Either side of the process we have a swim lane containing Partner Links that represent either the caller of our process, as is the case with the echoprocess_client partner links, or services that our BPEL process calls out to. At the moment this is empty as we haven't defined any external references that we use within our BPEL process. Notice also that we don't currently have any content between receiving the call and replying; our process is empty and does nothing.
The Component Palette window (to the right of our process window in the preceding screenshot) lists all the BPEL Activities and Components that we can use within our process. To use any of these, we have to simply drag-and-drop them onto the appropriate place within our process.
If you click on the BPEL Services drop-down, you also have the option of selecting services which we use whenever we need to call out to an external system.
Getting back to our skeleton process, we can see that it consists of two activities; receiveInput and replyOutput. In addition it has two variables, inputVariable
and outputVariable
, which were created as part of our skeleton process.
The first activity is used to receive the initial request from the client invoking our BPEL process; when this request is received it will populate the variable inputVariable
with the content of the request.
The last activity is used to send a response back to the client, and the content of this response will contain the content of outputVariable
.
For the purpose of our simple EchoProcess
we just need to copy the content of the input variable to the output variable.
Assigning values to variables
In BPEL, the <assign>
activity is used to update the values of variables with new data. The <assign>
activity typically consists of one or more copy operations. Each copy consists of a target variable, that is, the variable that you wish to assign a value to and a source, which can either be another variable or an XPath expression.
To insert an Assign activity, drag one from the Component Palette on to our BPEL process at the point just after the receiveInput activity, as shown in the following screenshot:
To configure the Assign activity, double-click on it to open up its configuration window. Click on the green cross to access a menu and select Copy Operation…, as shown in the next screenshot:
This will present us with the Create Copy Operation window, as shown in the following screenshot:
On the left-hand side, we specify the From variable, that is, where we want to copy from. For our process, we want to copy the content of our input variable to our output variable. So expand inputVariable and select /client:process/client:input, as shown in the preceding screenshot.
On the right-hand side, we specify the To variable, that is, where we want to copy to. So expand outputVariable and select /client:processResponse/client:result.
Once you've done this, click OK and then OK again to close the Assign window.
This completes our process, so click on the Save All icon (the fourth icon along, in the top-left-hand corner of JDeveloper) to save our work.
Note
As a BPEL project is made up of multiple files, we typically use Save All to ensure that all modifications are updated at the same time.
Our process is now ready to be deployed. Before doing this, make sure the SOA Suite is running and that within JDeveloper we have defined an Application Server connection (as described in the installation guide).
To deploy the process, right-click on our EchoComposite project and then select Deploy | EchoComposite | to MyApplicationServerConnection.
This will bring up the SOA Deployment Configuration Dialog. This dialog allows us to specify the target servers onto which we wish to deploy the composite. We may also specify a Revision ID for the composite to differentiate it from other deployed versions of the composite. If a revision with the same ID already exists, then it may be replaced by specifying the Overwrite any existing composites with the same revision ID option.
Clicking OK will begin the build and deployment of the composite. JDeveloper will open up a window below our process containing five tabs: Messages, Feedback, BPEL, Deployment, and SOA, to which it outputs the status of the deployment process.
During the build, the SOA tab will indicate if the build was successful, and assuming it was, then an Authorization Request window will pop up requesting credentials for the application server.
On completion of the build process, the Deployment tab should state Successfully deployed archive…., as shown in the following screenshot:
If you don't get this message, then check the log windows for details of the error and fix it accordingly.
Now that our process has been deployed, the next step is to run it. A simple way to do this is to initiate a test instance using the Enterprise Manager (EM) console, which is the web-based management console for SOA Suite.
To access the EM console, open up a browser and enter the following URL:
This will bring up the login screen for the EM console. Log in as weblogic. This will take us to the EM console dashboard, as shown in the following screenshot:
The Dashboard provides us with a summary report on the Fusion Middleware domain. On the left-hand side we have a list of management areas and on the right we have summaries of application deployments, including our EchoComposite under the SOA tab.
From here, click on the composite name, that is, EchoComposite. This will take us to the Dashboard screen for our composite. From here we can see the number of completed and currently executing composite instances.
At the top of the Dashboard there is a Test button that allows us to execute a composite test. Pressing this button brings up the Test Web Service page, as shown in the following screenshot:
When we created our process, JDeveloper automatically created a WSDL file which contained the single operation (that is, process
). However, it's quite common to define processes that have multiple operations, as we will see later on in the book.
The Operation drop-down list allows us to specify which operation we want to invoke. In our case, it's automatically defaulted to process.
When you select the operation to invoke, the console will generate an HTML form with a field for each element in the message payload of the operation (as defined by the WSDL for the process). Here we can enter into each field the value that we want to submit.
For operations with large message payloads it can be simpler to just enter the XML source. If you select the XML View drop-down list the console will replace the form with a free text area with a skeleton XML fragment into which we can insert the required values.
To execute a test instance of our composite, enter some text in the input field and click Test Web Service. This will cause the console to generate a SOAP message and use it to invoke our Echo process.
Upon successful execution of the process, our test page will be updated to show the result which displays the response returned by our process. Here we can see that the result element contains our original input string, as shown in the following screenshot:
If we expand the SOA and soa-infra items on the left-hand side of the page, we will arrive back at the dashboard for the EchoComposite. Clicking on a completed instance will give us a summary of the composite. From here we can see the components that make up our composite. In this case, the composite consists of a single BPEL process.
Clicking on the BPEL process takes us to an audit record of the instance. We can expand the tree view to see details of individual operations like the message sent by replyOutput.
Clicking on the Flow tab will display a graphical representation of the activities within the BPEL process.
Clicking on any of the activities in the audit trail will pop up a window displaying details of the actions performed by that activity. In the following screenshot, we can see details of the message sent by the replyOutput activity:
This completes development of our first BPEL process. The next step is to call it via the Mediator. This will give us the option of transforming the input into the format we desire and of routing to different components based on the input content.
By selecting the composite.xml tab in JDeveloper, we can see the outline of the Assembly that we have created for the BPEL process. We can add a Mediator to this by dragging it from the Component Palette.
Dragging the Mediator Component will cause a dialog to be displayed requesting a Name and Template for the Mediator.
If we select the Define Interface Later template, then we can click OK to add a Mediator to our Assembly. Defining the interface later will allow us to define the interface by wiring it to a service.
Note that the types of interface templates are the same as the ones we saw for our BPEL process.
We want to have the Mediator use the same interface as the BPEL process. To rewire the composite to use a Mediator, we first delete the line joining the EchoProcess in the Exposed Services swimlane to the BPEL process by right-clicking on the line and selecting Delete.
We
can now wire the EchoProcess service to the input of the Mediator by clicking on the chevron in the top-right corner of the exposed service and dragging it onto the connection point on the left-hand side of the Mediator.
Now wire the Mediator to the BPEL process by dragging the yellow arrow on the Mediator onto the blue chevron on the BPEL process.
We have now configured the Mediator to accept the same interface as the BPEL process and wired the Mediator to forward all messages onto the BPEL process. The default behavior of the Mediator, if it has no explicit rules, is to route the input request to the outbound request and then route the response, if any, from the target to the client.
We
can now deploy and test the Assembly containing the Mediator in the same way that we deployed and tested the Assembly containing the BPEL process.
In preparation for this, we will need the URL for the WSDL of our process. To obtain this, from the EM Dashboard, click on the EchoComposite Assembly, and then the connector icon to the right of the Settings button. This will display a link for the WSDL location and Endpoint, as shown in the following screenshot:
If you click on this link, the EM console will open a window showing details of the WSDL. Make a note of the WSDL location as we will need this in a moment.
Assigning values to variables
In BPEL, the <assign>
activity is used to update the values of variables with new data. The <assign>
activity typically consists of one or more copy operations. Each copy consists of a target variable, that is, the variable that you wish to assign a value to and a source, which can either be another variable or an XPath expression.
To insert an Assign activity, drag one from the Component Palette on to our BPEL process at the point just after the receiveInput activity, as shown in the following screenshot:
To configure the Assign activity, double-click on it to open up its configuration window. Click on the green cross to access a menu and select Copy Operation…, as shown in the next screenshot:
This will present us with the Create Copy Operation window, as shown in the following screenshot:
On the left-hand side, we specify the From variable, that is, where we want to copy from. For our process, we want to copy the content of our input variable to our output variable. So expand inputVariable and select /client:process/client:input, as shown in the preceding screenshot.
On the right-hand side, we specify the To variable, that is, where we want to copy to. So expand outputVariable and select /client:processResponse/client:result.
Once you've done this, click OK and then OK again to close the Assign window.
This completes our process, so click on the Save All icon (the fourth icon along, in the top-left-hand corner of JDeveloper) to save our work.
Note
As a BPEL project is made up of multiple files, we typically use Save All to ensure that all modifications are updated at the same time.
Our process is now ready to be deployed. Before doing this, make sure the SOA Suite is running and that within JDeveloper we have defined an Application Server connection (as described in the installation guide).
To deploy the process, right-click on our EchoComposite project and then select Deploy | EchoComposite | to MyApplicationServerConnection.
This will bring up the SOA Deployment Configuration Dialog. This dialog allows us to specify the target servers onto which we wish to deploy the composite. We may also specify a Revision ID for the composite to differentiate it from other deployed versions of the composite. If a revision with the same ID already exists, then it may be replaced by specifying the Overwrite any existing composites with the same revision ID option.
Clicking OK will begin the build and deployment of the composite. JDeveloper will open up a window below our process containing five tabs: Messages, Feedback, BPEL, Deployment, and SOA, to which it outputs the status of the deployment process.
During the build, the SOA tab will indicate if the build was successful, and assuming it was, then an Authorization Request window will pop up requesting credentials for the application server.
On completion of the build process, the Deployment tab should state Successfully deployed archive…., as shown in the following screenshot:
If you don't get this message, then check the log windows for details of the error and fix it accordingly.
Now that our process has been deployed, the next step is to run it. A simple way to do this is to initiate a test instance using the Enterprise Manager (EM) console, which is the web-based management console for SOA Suite.
To access the EM console, open up a browser and enter the following URL:
This will bring up the login screen for the EM console. Log in as weblogic. This will take us to the EM console dashboard, as shown in the following screenshot:
The Dashboard provides us with a summary report on the Fusion Middleware domain. On the left-hand side we have a list of management areas and on the right we have summaries of application deployments, including our EchoComposite under the SOA tab.
From here, click on the composite name, that is, EchoComposite. This will take us to the Dashboard screen for our composite. From here we can see the number of completed and currently executing composite instances.
At the top of the Dashboard there is a Test button that allows us to execute a composite test. Pressing this button brings up the Test Web Service page, as shown in the following screenshot:
When we created our process, JDeveloper automatically created a WSDL file which contained the single operation (that is, process
). However, it's quite common to define processes that have multiple operations, as we will see later on in the book.
The Operation drop-down list allows us to specify which operation we want to invoke. In our case, it's automatically defaulted to process.
When you select the operation to invoke, the console will generate an HTML form with a field for each element in the message payload of the operation (as defined by the WSDL for the process). Here we can enter into each field the value that we want to submit.
For operations with large message payloads it can be simpler to just enter the XML source. If you select the XML View drop-down list the console will replace the form with a free text area with a skeleton XML fragment into which we can insert the required values.
To execute a test instance of our composite, enter some text in the input field and click Test Web Service. This will cause the console to generate a SOAP message and use it to invoke our Echo process.
Upon successful execution of the process, our test page will be updated to show the result which displays the response returned by our process. Here we can see that the result element contains our original input string, as shown in the following screenshot:
If we expand the SOA and soa-infra items on the left-hand side of the page, we will arrive back at the dashboard for the EchoComposite. Clicking on a completed instance will give us a summary of the composite. From here we can see the components that make up our composite. In this case, the composite consists of a single BPEL process.
Clicking on the BPEL process takes us to an audit record of the instance. We can expand the tree view to see details of individual operations like the message sent by replyOutput.
Clicking on the Flow tab will display a graphical representation of the activities within the BPEL process.
Clicking on any of the activities in the audit trail will pop up a window displaying details of the actions performed by that activity. In the following screenshot, we can see details of the message sent by the replyOutput activity:
This completes development of our first BPEL process. The next step is to call it via the Mediator. This will give us the option of transforming the input into the format we desire and of routing to different components based on the input content.
By selecting the composite.xml tab in JDeveloper, we can see the outline of the Assembly that we have created for the BPEL process. We can add a Mediator to this by dragging it from the Component Palette.
Dragging the Mediator Component will cause a dialog to be displayed requesting a Name and Template for the Mediator.
If we select the Define Interface Later template, then we can click OK to add a Mediator to our Assembly. Defining the interface later will allow us to define the interface by wiring it to a service.
Note that the types of interface templates are the same as the ones we saw for our BPEL process.
We want to have the Mediator use the same interface as the BPEL process. To rewire the composite to use a Mediator, we first delete the line joining the EchoProcess in the Exposed Services swimlane to the BPEL process by right-clicking on the line and selecting Delete.
We
can now wire the EchoProcess service to the input of the Mediator by clicking on the chevron in the top-right corner of the exposed service and dragging it onto the connection point on the left-hand side of the Mediator.
Now wire the Mediator to the BPEL process by dragging the yellow arrow on the Mediator onto the blue chevron on the BPEL process.
We have now configured the Mediator to accept the same interface as the BPEL process and wired the Mediator to forward all messages onto the BPEL process. The default behavior of the Mediator, if it has no explicit rules, is to route the input request to the outbound request and then route the response, if any, from the target to the client.
We
can now deploy and test the Assembly containing the Mediator in the same way that we deployed and tested the Assembly containing the BPEL process.
In preparation for this, we will need the URL for the WSDL of our process. To obtain this, from the EM Dashboard, click on the EchoComposite Assembly, and then the connector icon to the right of the Settings button. This will display a link for the WSDL location and Endpoint, as shown in the following screenshot:
If you click on this link, the EM console will open a window showing details of the WSDL. Make a note of the WSDL location as we will need this in a moment.
This completes our process, so click on the Save All icon (the fourth icon along, in the top-left-hand corner of JDeveloper) to save our work.
Note
As a BPEL project is made up of multiple files, we typically use Save All to ensure that all modifications are updated at the same time.
Our process is now ready to be deployed. Before doing this, make sure the SOA Suite is running and that within JDeveloper we have defined an Application Server connection (as described in the installation guide).
To deploy the process, right-click on our EchoComposite project and then select Deploy | EchoComposite | to MyApplicationServerConnection.
This will bring up the SOA Deployment Configuration Dialog. This dialog allows us to specify the target servers onto which we wish to deploy the composite. We may also specify a Revision ID for the composite to differentiate it from other deployed versions of the composite. If a revision with the same ID already exists, then it may be replaced by specifying the Overwrite any existing composites with the same revision ID option.
Clicking OK will begin the build and deployment of the composite. JDeveloper will open up a window below our process containing five tabs: Messages, Feedback, BPEL, Deployment, and SOA, to which it outputs the status of the deployment process.
During the build, the SOA tab will indicate if the build was successful, and assuming it was, then an Authorization Request window will pop up requesting credentials for the application server.
On completion of the build process, the Deployment tab should state Successfully deployed archive…., as shown in the following screenshot:
If you don't get this message, then check the log windows for details of the error and fix it accordingly.
Now that our process has been deployed, the next step is to run it. A simple way to do this is to initiate a test instance using the Enterprise Manager (EM) console, which is the web-based management console for SOA Suite.
To access the EM console, open up a browser and enter the following URL:
This will bring up the login screen for the EM console. Log in as weblogic. This will take us to the EM console dashboard, as shown in the following screenshot:
The Dashboard provides us with a summary report on the Fusion Middleware domain. On the left-hand side we have a list of management areas and on the right we have summaries of application deployments, including our EchoComposite under the SOA tab.
From here, click on the composite name, that is, EchoComposite. This will take us to the Dashboard screen for our composite. From here we can see the number of completed and currently executing composite instances.
At the top of the Dashboard there is a Test button that allows us to execute a composite test. Pressing this button brings up the Test Web Service page, as shown in the following screenshot:
When we created our process, JDeveloper automatically created a WSDL file which contained the single operation (that is, process
). However, it's quite common to define processes that have multiple operations, as we will see later on in the book.
The Operation drop-down list allows us to specify which operation we want to invoke. In our case, it's automatically defaulted to process.
When you select the operation to invoke, the console will generate an HTML form with a field for each element in the message payload of the operation (as defined by the WSDL for the process). Here we can enter into each field the value that we want to submit.
For operations with large message payloads it can be simpler to just enter the XML source. If you select the XML View drop-down list the console will replace the form with a free text area with a skeleton XML fragment into which we can insert the required values.
To execute a test instance of our composite, enter some text in the input field and click Test Web Service. This will cause the console to generate a SOAP message and use it to invoke our Echo process.
Upon successful execution of the process, our test page will be updated to show the result which displays the response returned by our process. Here we can see that the result element contains our original input string, as shown in the following screenshot:
If we expand the SOA and soa-infra items on the left-hand side of the page, we will arrive back at the dashboard for the EchoComposite. Clicking on a completed instance will give us a summary of the composite. From here we can see the components that make up our composite. In this case, the composite consists of a single BPEL process.
Clicking on the BPEL process takes us to an audit record of the instance. We can expand the tree view to see details of individual operations like the message sent by replyOutput.
Clicking on the Flow tab will display a graphical representation of the activities within the BPEL process.
Clicking on any of the activities in the audit trail will pop up a window displaying details of the actions performed by that activity. In the following screenshot, we can see details of the message sent by the replyOutput activity:
This completes development of our first BPEL process. The next step is to call it via the Mediator. This will give us the option of transforming the input into the format we desire and of routing to different components based on the input content.
By selecting the composite.xml tab in JDeveloper, we can see the outline of the Assembly that we have created for the BPEL process. We can add a Mediator to this by dragging it from the Component Palette.
Dragging the Mediator Component will cause a dialog to be displayed requesting a Name and Template for the Mediator.
If we select the Define Interface Later template, then we can click OK to add a Mediator to our Assembly. Defining the interface later will allow us to define the interface by wiring it to a service.
Note that the types of interface templates are the same as the ones we saw for our BPEL process.
We want to have the Mediator use the same interface as the BPEL process. To rewire the composite to use a Mediator, we first delete the line joining the EchoProcess in the Exposed Services swimlane to the BPEL process by right-clicking on the line and selecting Delete.
We
can now wire the EchoProcess service to the input of the Mediator by clicking on the chevron in the top-right corner of the exposed service and dragging it onto the connection point on the left-hand side of the Mediator.
Now wire the Mediator to the BPEL process by dragging the yellow arrow on the Mediator onto the blue chevron on the BPEL process.
We have now configured the Mediator to accept the same interface as the BPEL process and wired the Mediator to forward all messages onto the BPEL process. The default behavior of the Mediator, if it has no explicit rules, is to route the input request to the outbound request and then route the response, if any, from the target to the client.
We
can now deploy and test the Assembly containing the Mediator in the same way that we deployed and tested the Assembly containing the BPEL process.
In preparation for this, we will need the URL for the WSDL of our process. To obtain this, from the EM Dashboard, click on the EchoComposite Assembly, and then the connector icon to the right of the Settings button. This will display a link for the WSDL location and Endpoint, as shown in the following screenshot:
If you click on this link, the EM console will open a window showing details of the WSDL. Make a note of the WSDL location as we will need this in a moment.
Now that our process has been deployed, the next step is to run it. A simple way to do this is to initiate a test instance using the Enterprise Manager (EM) console, which is the web-based management console for SOA Suite.
To access the EM console, open up a browser and enter the following URL:
This will bring up the login screen for the EM console. Log in as weblogic. This will take us to the EM console dashboard, as shown in the following screenshot:
The Dashboard provides us with a summary report on the Fusion Middleware domain. On the left-hand side we have a list of management areas and on the right we have summaries of application deployments, including our EchoComposite under the SOA tab.
From here, click on the composite name, that is, EchoComposite. This will take us to the Dashboard screen for our composite. From here we can see the number of completed and currently executing composite instances.
At the top of the Dashboard there is a Test button that allows us to execute a composite test. Pressing this button brings up the Test Web Service page, as shown in the following screenshot:
When we created our process, JDeveloper automatically created a WSDL file which contained the single operation (that is, process
). However, it's quite common to define processes that have multiple operations, as we will see later on in the book.
The Operation drop-down list allows us to specify which operation we want to invoke. In our case, it's automatically defaulted to process.
When you select the operation to invoke, the console will generate an HTML form with a field for each element in the message payload of the operation (as defined by the WSDL for the process). Here we can enter into each field the value that we want to submit.
For operations with large message payloads it can be simpler to just enter the XML source. If you select the XML View drop-down list the console will replace the form with a free text area with a skeleton XML fragment into which we can insert the required values.
To execute a test instance of our composite, enter some text in the input field and click Test Web Service. This will cause the console to generate a SOAP message and use it to invoke our Echo process.
Upon successful execution of the process, our test page will be updated to show the result which displays the response returned by our process. Here we can see that the result element contains our original input string, as shown in the following screenshot:
If we expand the SOA and soa-infra items on the left-hand side of the page, we will arrive back at the dashboard for the EchoComposite. Clicking on a completed instance will give us a summary of the composite. From here we can see the components that make up our composite. In this case, the composite consists of a single BPEL process.
Clicking on the BPEL process takes us to an audit record of the instance. We can expand the tree view to see details of individual operations like the message sent by replyOutput.
Clicking on the Flow tab will display a graphical representation of the activities within the BPEL process.
Clicking on any of the activities in the audit trail will pop up a window displaying details of the actions performed by that activity. In the following screenshot, we can see details of the message sent by the replyOutput activity:
This completes development of our first BPEL process. The next step is to call it via the Mediator. This will give us the option of transforming the input into the format we desire and of routing to different components based on the input content.
By selecting the composite.xml tab in JDeveloper, we can see the outline of the Assembly that we have created for the BPEL process. We can add a Mediator to this by dragging it from the Component Palette.
Dragging the Mediator Component will cause a dialog to be displayed requesting a Name and Template for the Mediator.
If we select the Define Interface Later template, then we can click OK to add a Mediator to our Assembly. Defining the interface later will allow us to define the interface by wiring it to a service.
Note that the types of interface templates are the same as the ones we saw for our BPEL process.
We want to have the Mediator use the same interface as the BPEL process. To rewire the composite to use a Mediator, we first delete the line joining the EchoProcess in the Exposed Services swimlane to the BPEL process by right-clicking on the line and selecting Delete.
We
can now wire the EchoProcess service to the input of the Mediator by clicking on the chevron in the top-right corner of the exposed service and dragging it onto the connection point on the left-hand side of the Mediator.
Now wire the Mediator to the BPEL process by dragging the yellow arrow on the Mediator onto the blue chevron on the BPEL process.
We have now configured the Mediator to accept the same interface as the BPEL process and wired the Mediator to forward all messages onto the BPEL process. The default behavior of the Mediator, if it has no explicit rules, is to route the input request to the outbound request and then route the response, if any, from the target to the client.
We
can now deploy and test the Assembly containing the Mediator in the same way that we deployed and tested the Assembly containing the BPEL process.
In preparation for this, we will need the URL for the WSDL of our process. To obtain this, from the EM Dashboard, click on the EchoComposite Assembly, and then the connector icon to the right of the Settings button. This will display a link for the WSDL location and Endpoint, as shown in the following screenshot:
If you click on this link, the EM console will open a window showing details of the WSDL. Make a note of the WSDL location as we will need this in a moment.
Writing our first proxy service
Rather than allowing clients to directly invoke our Echo process, best practice dictates that we provide access to this service via an intermediary or proxy, whose role is to route the request to the actual endpoint. This results in a far more loosely-coupled solution, which is the key if we are to realise many of the benefits of SOA.
In this section, we are going to use the Oracle Service Bus (OSB) to implement a proxy Echo service, which sits between the client and our echo BPEL process, as illustrated in the following diagram:
It is useful to examine the preceding scenario to understand how messages are processed by OSB. The Service Bus defines two types of services, a proxy service and a business service.
The proxy service is an intermediary service that sits between the client and the actual end service being invoked (our BPEL process in the preceding example).
On receipt of a request the proxy service may perform a number of actions, such as validating, transforming, or enriching it before routing it to the appropriate business service.
Within the OSB, a business service is a definition of an external service for which OSB is a client. This defines whether OSB can invoke the external service and includes details such as the service interface, transport, security, and so on.
In the preceding example, we have defined an Echo Proxy Service that routes messages to the Echo Business Service, which then invokes our Echo BPEL Process. The response from the Echo BPEL Process follows the reverse path with the proxy service returning the final response to the original client.
Writing the Echo proxy service
Ensure that the Oracle Service Bus has started and then open up the Service Bus Console. Either do this from the Programs menu in Windows, select Oracle Weblogic | User Projects | OSB | Oracle Service Bus Admin Console
Or alternatively, open up a browser, and enter the following URL:
Where hostname represents the name of the machine on which OSB is running and port represents the port number. So if OSB is running on your local machine using the default port, enter the following URL in your browser:
This will bring up the login screen for the Service Bus Console, log in as weblogic. By default, the OSB Console will display the Dashboard view, which provides a summary of the overall health of the system.
Looking at the console, we can see that it is divided into three distinct areas. The Change Center in the top-left-hand corner, which we will cover in a moment. Also on the left, below the Change Center, is the navigation bar which we use to navigate our way round the console.
The navigation bar is divided into the following sections: Operations, Resource Browser, Project Explorer, Security Configuration, and System Administration. Clicking on the appropriate section will expand that part of the navigation bar and allow you to access any of its sub-sections and their corresponding menu items.
Clicking on any of the menu items will display the appropriate page within the main window of the console. In the previous diagram we looked at the Dashboard view, under Monitoring, which is part of the Operations section.
Creating a Change Session
Before
we can create a new project, or make any configuration changes through the console, we must create a new change session. A Change Session allows us to specify a series of changes as a single unit of work. These changes won't come into effect until we activate a session. At any point we can discard our changes, which will cause OSB to roll back those changes and exit our session.
While making changes through a session, other users can also be making changes under separate sessions. If users create changes that conflict with changes in other sessions, then the Service Bus will flag that as a conflict in the Change Center and neither user will be able to commit their changes until those conflicts have been resolved.
To create a new change session, click on Create in the Change Center. This will update the Change Center to indicate that we are in a session and the user who owns that session. As we are logged in as weblogic, it will be updated to show weblogic session, as shown in the following screenshot:
In addition, you will see that the options available to us in the Change Center have changed to Activate, Discard, and Exit.
Before we can create our Echo proxy service, we must create an OSB project in which to place our resources. Typical resources include WSDL, XSD schemas, XSLT, and XQuery as well as Proxy and Business Services.
Resources can be created directly within our top-level project folder, or we can define a folder structure within our project into which we can place our resources.
Note
From within the same OSB domain, you can reference any resource regardless of which project it is included in.
The Project Explorer is where we create and manage all of this. Click on the Project Explorer section within the navigation bar. This will bring up the Projects view, as shown in the following screenshot:
Here we can see a list of all projects defined in OSB, which at this stage just includes the default project. From here we can also create a new project. Enter a project name, for example Chapter02, as shown in the preceding screenshot, and then click Add Project. This will create a new project and update our list of projects to reflect this.
Creating the project folders
Click on the project name will take us to the Project View, as shown in the screenshot on the next page.
We can see that this splits into three sections. The first section provides some basic details about the project including any references to or from artifacts in other projects as well as an optional description.
The second section lists any folders within the current project folder and provides the option to create additional folders within the project.
The final section lists any resource contained within this folder and provides the option to create additional resource.
We are going to create the project folders BusinessService, ProxyService, and WSDL, into which we will place our various resources. To create the first of these, in the Folders section, enter BusinessService as the folder name (circled in the preceding screenshot) and click on Add Folder. This will create a new folder and updates the list of folders to reflect this.
Once created, follow the same process to create the remaining folders; your list of folders will now look as shown in the preceding screenshot.
Before we
can create either our proxy or business service, we need to define the WSDL on which the service will be based. For this, we are going to use the WSDL of our Echo
BPEL process that we created earlier in this chapter.
Before importing the WSDL, we need to ensure that we are in the right folder within our project. To do this, click on the WSDL folder in our Folders list. On doing this the project view will be updated to show us the content of this folder, which is currently empty. In addition, the project summary section of our project view will be updated to show that we are now within the WSDL
folder, as circled in the following screenshot:
If we look at the Project Explorer in the navigation bar, we can see that it has been updated to show our location within the projects structure. By clicking on any project or folder in here, the console will take us to the project view for that location.
To import the
Echo WSDL into our project, click on the drop-down list next to Create Resource in the Resources section, and select Resources from URL, as shown in the following screenshot:
This will bring
up the page for loading resources from a URL, which is shown in the following screenshot:
Note
A WSDL can also be imported from the filesystem by selecting the WSDL option from the Create Resource drop-down list.
In the URL/Path, enter the URL for our Echo WSDL. This is the WSDL location we made a note of earlier (in the WSDL tab for the Echo process in the BPEL console) and should look like the following:
Enter an appropriate value for the Resource Name(for example Echo), select a Resource Type as WSDL, and click on Next.
This will bring up the Load Resources window, which will list the resources that OSB is ready to import.
You will notice that in addition to the actual WSDL file, it will also list the Echo.xsd. This is because the Echo.wsdl contains the following import statement:
This imports the Echo XML schema, which defines the input and output message of our Echo service. This schema was automatically generated by JDeveloper when we created our Echo process. In order to use our WSDL, we will need to import this schema as well. Because of the unusual URL for the XML Schema, the Service Bus generates its own unique name for the schema.
Click Import, the OSB console will confirm that the resources have been successfully imported and provide the option to Load Another resource, as shown in the following screenshot:
Click on the WSDL folder within the project explorer to return to its project view. This will be updated to include our imported resources, as shown in the following screenshot:
Creating our business service
We are now ready to
create our Echo business service. Click on the Business Service folder within the Project Explorer to go to the project view for this folder.
In the Resources section, click on the drop-down list next to Create Resource and select Business Service. This will bring up the General Configuration page for creating a business service, as shown in the following screenshot:
Here we specify the name of our business service (that is, EchoBS) and an optional description. Next we need to specify the Service Type, as we are creating our service based on a WSDL select WSDL Web Service.
Next, click the Browse button. This will launch a window from where we can select the WSDL for the Business Service, as shown on the next page:
By default, this window will list all WSDL resources that are defined to the Service Bus, though you can restrict the list by defining the search criteria.
In our case, we just have the Echo WSDL, so we click on this. We will now be prompted to select a WSDL definition, as shown in the following screenshot:
Here we need to select which binding or port definition we wish to use for our Business Service, select EchoProcess_pt and click Submit. Bindings provide an abstract interface and do not specify the physical endpoint, requiring additional configuration later. Ports have a physical endpoint and so require no additional configuration.
This will return us to the General Configuration screen with the Service Type updated to show the details of the selected WSDL and port, as shown in the following screenshot:
Then, click on Next. This will take us to the Transport Configuration page, as shown in the following screenshot. Here we need to specify how the business service is to invoke an external service.
As we based our business service on the EchoPort definition, the transport settings are already preconfigured, based on the content of our WSDL file.
Note
If we had based our business service on the EchoBinding definition, then the transport configuration would still have been prepopulated except for the Endpoint URI, which we would need to add manually.
From here, click on Last. This will take us to a summary page of our business service. Click on Save to create our business service.
This will return us to the project view on the Business Service folder and display the message The Service EchoBS was created successfully. If we examine the Resources section, we should see that it now contains our newly created business service.
Creating our proxy service
We are now ready to create our Echo proxy service. Click on the Proxy Service folder within the Project Explorer to go to the project view for this folder.
In the Resources section, click on the drop-down list next to Create Resource and select Proxy Service. This will bring up the General Configuration page for creating a proxy service, as shown in the following screenshot:
You will notice that this looks very similar to the general configuration screen for a business service. So as before, enter the name of our service (that is, Echo) and an optional description.
Next, we need to specify the Service Type. We could do this in exactly the same way as we did for our business service and base it on the Echo WSDL. However, this time we are going to base it on our EchoBS business service. We will see why in a moment.
For the Service Type, select Business Service, as shown in the screenshot, and click Browse…. This will launch the Select Business Service window from where we can search for and select the business service that we want to base our proxy service on.
By default, this window will list all the business services defined to the Service Bus, though you can restrict the list by defining the search criteria.
In our case, we just have the EchoBS, so select this, and click on Submit. This will return us to the General Configuration screen with Service Type updated, as shown in the following screenshot:
From here, click Last. This will take us to a summary page of our proxy service. Click Save to create our proxy service.
This will return us to the project view on the Proxy Service folder and display the message The Service Echo was created successfully.
If we examine the Resources section of our project view, we should see that it now contains our newly created proxy service as shown in the following screenshot:
Once we have created our
proxy service, the next step is to specify how it should handle requests. This is defined in the message flow of the proxy service.
The message flow defines the actions that the proxy service should perform when a request is received such as validating the payload, transforming, or enriching it before routing it to the appropriate business service.
Within the resource section of our project view, click on the Edit Message Flow icon, as circled in the preceding image. This will take us to the Edit Message Flow window, where we can view and edit the message flow of our proxy service, as shown in the following screenshot:
Looking at this, we can see that Echo already invokes the route node RouteTo_EchoBS.
Click on this and select Edit Route(as shown in the preceding screenshot). This will take us to the Edit Stage Configuration window, as shown in the following screenshot:
Here we can see that it's already configured to route requests to the EchoBS business service.
Normally, when we create a proxy service we have to specify the message flow from scratch. However, when we created our Echo proxy service we based it on the EchoBS business service (as opposed to a WSDL). Because of this, the Service Bus has automatically configured the message flow to route requests to EchoBS.
As a result, our message flow is already predefined for us, so click Cancel, and then Cancel again to return to our project view.
Activating the Echo proxy service
We now have a completed proxy service; all that remains is to commit our work. Within the Change Center click Activate.
This will bring up the Activate Session, as shown in the following screenshot:
Before activating a session, it's good practice to give a description of the changes that we've made, just in case we need to roll them back later. So enter an appropriate description and then click on Submit, as shown in the preceding screenshot:
Assuming everything is okay, this will activate our changes, and the console will be updated to list our configuration changes, as shown in the following screenshot:
If you make a mistake and want to undo the changes you have activated, then you can click on the undo icon (circled in the preceding screenshot), and if you change your mind, you can revert the undo.
OSB allows you to undo any of your previous sessions as long as it doesn't result in an error in the runtime configuration of the Service Bus.
Testing our proxy service
All that's left is to test our proxy service. A simple way to do this is to initiate a test instance using the Service Bus test console.
To do this, we need to navigate back to the definition of our proxy service, rather than do this via the Project Explorer. We will use the Resource Browser. This provides a way to view all resources based on their type.
Click on the Resource Browser section within the navigation bar. By default, it will list all proxy services defined to the Service Bus, as shown in the following screenshot:
We can then filter this list further by specifying the appropriate search criteria.
Click on the Launch Test Console icon for the Echo proxy service (circled in the preceding screenshot). This will launch the test console shown on the next page.
The
Available Operations drop-down list allows us to specify which operation we want to invoke. In our case, it's automatically defaulted to process.
By default, the options Direct Call and Include Tracing are selected within the Test Configuration section; keep these selected as they enable us to trace the state of a message as it passes through the proxy service.
The Request Document section allows us to specify the SOAP Header and the Payload for our service. By default, these will contain a skeleton XML fragment based on the WSDL definition of the selected operation with default values for each field.
To execute a test instance of our service, modify the text in the <echo:input>
element, as we have in the following screen shot, and click Execute. This will cause the console to generate a request message and use it to invoke our Echo proxy service.
Upon successful execution of the proxy, the test console will be updated to show the response returned. Here we can see that the result
element contains our original initial input string, as shown in the following screenshot:
We can examine the state of our message as it passed through the proxy service by expanding the Invocation Trace, as we have in the following screenshot:
In addition, if you log back into the EM console, you should be able to see the Assembly instance that was invoked by the Service Bus.
Writing the Echo proxy service
Ensure that the Oracle Service Bus has started and then open up the Service Bus Console. Either do this from the Programs menu in Windows, select Oracle Weblogic | User Projects | OSB | Oracle Service Bus Admin Console
Or alternatively, open up a browser, and enter the following URL:
Where hostname represents the name of the machine on which OSB is running and port represents the port number. So if OSB is running on your local machine using the default port, enter the following URL in your browser:
This will bring up the login screen for the Service Bus Console, log in as weblogic. By default, the OSB Console will display the Dashboard view, which provides a summary of the overall health of the system.
Looking at the console, we can see that it is divided into three distinct areas. The Change Center in the top-left-hand corner, which we will cover in a moment. Also on the left, below the Change Center, is the navigation bar which we use to navigate our way round the console.
The navigation bar is divided into the following sections: Operations, Resource Browser, Project Explorer, Security Configuration, and System Administration. Clicking on the appropriate section will expand that part of the navigation bar and allow you to access any of its sub-sections and their corresponding menu items.
Clicking on any of the menu items will display the appropriate page within the main window of the console. In the previous diagram we looked at the Dashboard view, under Monitoring, which is part of the Operations section.
Creating a Change Session
Before
we can create a new project, or make any configuration changes through the console, we must create a new change session. A Change Session allows us to specify a series of changes as a single unit of work. These changes won't come into effect until we activate a session. At any point we can discard our changes, which will cause OSB to roll back those changes and exit our session.
While making changes through a session, other users can also be making changes under separate sessions. If users create changes that conflict with changes in other sessions, then the Service Bus will flag that as a conflict in the Change Center and neither user will be able to commit their changes until those conflicts have been resolved.
To create a new change session, click on Create in the Change Center. This will update the Change Center to indicate that we are in a session and the user who owns that session. As we are logged in as weblogic, it will be updated to show weblogic session, as shown in the following screenshot:
In addition, you will see that the options available to us in the Change Center have changed to Activate, Discard, and Exit.
Before we can create our Echo proxy service, we must create an OSB project in which to place our resources. Typical resources include WSDL, XSD schemas, XSLT, and XQuery as well as Proxy and Business Services.
Resources can be created directly within our top-level project folder, or we can define a folder structure within our project into which we can place our resources.
Note
From within the same OSB domain, you can reference any resource regardless of which project it is included in.
The Project Explorer is where we create and manage all of this. Click on the Project Explorer section within the navigation bar. This will bring up the Projects view, as shown in the following screenshot:
Here we can see a list of all projects defined in OSB, which at this stage just includes the default project. From here we can also create a new project. Enter a project name, for example Chapter02, as shown in the preceding screenshot, and then click Add Project. This will create a new project and update our list of projects to reflect this.
Creating the project folders
Click on the project name will take us to the Project View, as shown in the screenshot on the next page.
We can see that this splits into three sections. The first section provides some basic details about the project including any references to or from artifacts in other projects as well as an optional description.
The second section lists any folders within the current project folder and provides the option to create additional folders within the project.
The final section lists any resource contained within this folder and provides the option to create additional resource.
We are going to create the project folders BusinessService, ProxyService, and WSDL, into which we will place our various resources. To create the first of these, in the Folders section, enter BusinessService as the folder name (circled in the preceding screenshot) and click on Add Folder. This will create a new folder and updates the list of folders to reflect this.
Once created, follow the same process to create the remaining folders; your list of folders will now look as shown in the preceding screenshot.
Before we
can create either our proxy or business service, we need to define the WSDL on which the service will be based. For this, we are going to use the WSDL of our Echo
BPEL process that we created earlier in this chapter.
Before importing the WSDL, we need to ensure that we are in the right folder within our project. To do this, click on the WSDL folder in our Folders list. On doing this the project view will be updated to show us the content of this folder, which is currently empty. In addition, the project summary section of our project view will be updated to show that we are now within the WSDL
folder, as circled in the following screenshot:
If we look at the Project Explorer in the navigation bar, we can see that it has been updated to show our location within the projects structure. By clicking on any project or folder in here, the console will take us to the project view for that location.
To import the
Echo WSDL into our project, click on the drop-down list next to Create Resource in the Resources section, and select Resources from URL, as shown in the following screenshot:
This will bring
up the page for loading resources from a URL, which is shown in the following screenshot:
Note
A WSDL can also be imported from the filesystem by selecting the WSDL option from the Create Resource drop-down list.
In the URL/Path, enter the URL for our Echo WSDL. This is the WSDL location we made a note of earlier (in the WSDL tab for the Echo process in the BPEL console) and should look like the following:
Enter an appropriate value for the Resource Name(for example Echo), select a Resource Type as WSDL, and click on Next.
This will bring up the Load Resources window, which will list the resources that OSB is ready to import.
You will notice that in addition to the actual WSDL file, it will also list the Echo.xsd. This is because the Echo.wsdl contains the following import statement:
This imports the Echo XML schema, which defines the input and output message of our Echo service. This schema was automatically generated by JDeveloper when we created our Echo process. In order to use our WSDL, we will need to import this schema as well. Because of the unusual URL for the XML Schema, the Service Bus generates its own unique name for the schema.
Click Import, the OSB console will confirm that the resources have been successfully imported and provide the option to Load Another resource, as shown in the following screenshot:
Click on the WSDL folder within the project explorer to return to its project view. This will be updated to include our imported resources, as shown in the following screenshot:
Creating our business service
We are now ready to
create our Echo business service. Click on the Business Service folder within the Project Explorer to go to the project view for this folder.
In the Resources section, click on the drop-down list next to Create Resource and select Business Service. This will bring up the General Configuration page for creating a business service, as shown in the following screenshot:
Here we specify the name of our business service (that is, EchoBS) and an optional description. Next we need to specify the Service Type, as we are creating our service based on a WSDL select WSDL Web Service.
Next, click the Browse button. This will launch a window from where we can select the WSDL for the Business Service, as shown on the next page:
By default, this window will list all WSDL resources that are defined to the Service Bus, though you can restrict the list by defining the search criteria.
In our case, we just have the Echo WSDL, so we click on this. We will now be prompted to select a WSDL definition, as shown in the following screenshot:
Here we need to select which binding or port definition we wish to use for our Business Service, select EchoProcess_pt and click Submit. Bindings provide an abstract interface and do not specify the physical endpoint, requiring additional configuration later. Ports have a physical endpoint and so require no additional configuration.
This will return us to the General Configuration screen with the Service Type updated to show the details of the selected WSDL and port, as shown in the following screenshot:
Then, click on Next. This will take us to the Transport Configuration page, as shown in the following screenshot. Here we need to specify how the business service is to invoke an external service.
As we based our business service on the EchoPort definition, the transport settings are already preconfigured, based on the content of our WSDL file.
Note
If we had based our business service on the EchoBinding definition, then the transport configuration would still have been prepopulated except for the Endpoint URI, which we would need to add manually.
From here, click on Last. This will take us to a summary page of our business service. Click on Save to create our business service.
This will return us to the project view on the Business Service folder and display the message The Service EchoBS was created successfully. If we examine the Resources section, we should see that it now contains our newly created business service.
Creating our proxy service
We are now ready to create our Echo proxy service. Click on the Proxy Service folder within the Project Explorer to go to the project view for this folder.
In the Resources section, click on the drop-down list next to Create Resource and select Proxy Service. This will bring up the General Configuration page for creating a proxy service, as shown in the following screenshot:
You will notice that this looks very similar to the general configuration screen for a business service. So as before, enter the name of our service (that is, Echo) and an optional description.
Next, we need to specify the Service Type. We could do this in exactly the same way as we did for our business service and base it on the Echo WSDL. However, this time we are going to base it on our EchoBS business service. We will see why in a moment.
For the Service Type, select Business Service, as shown in the screenshot, and click Browse…. This will launch the Select Business Service window from where we can search for and select the business service that we want to base our proxy service on.
By default, this window will list all the business services defined to the Service Bus, though you can restrict the list by defining the search criteria.
In our case, we just have the EchoBS, so select this, and click on Submit. This will return us to the General Configuration screen with Service Type updated, as shown in the following screenshot:
From here, click Last. This will take us to a summary page of our proxy service. Click Save to create our proxy service.
This will return us to the project view on the Proxy Service folder and display the message The Service Echo was created successfully.
If we examine the Resources section of our project view, we should see that it now contains our newly created proxy service as shown in the following screenshot:
Once we have created our
proxy service, the next step is to specify how it should handle requests. This is defined in the message flow of the proxy service.
The message flow defines the actions that the proxy service should perform when a request is received such as validating the payload, transforming, or enriching it before routing it to the appropriate business service.
Within the resource section of our project view, click on the Edit Message Flow icon, as circled in the preceding image. This will take us to the Edit Message Flow window, where we can view and edit the message flow of our proxy service, as shown in the following screenshot:
Looking at this, we can see that Echo already invokes the route node RouteTo_EchoBS.
Click on this and select Edit Route(as shown in the preceding screenshot). This will take us to the Edit Stage Configuration window, as shown in the following screenshot:
Here we can see that it's already configured to route requests to the EchoBS business service.
Normally, when we create a proxy service we have to specify the message flow from scratch. However, when we created our Echo proxy service we based it on the EchoBS business service (as opposed to a WSDL). Because of this, the Service Bus has automatically configured the message flow to route requests to EchoBS.
As a result, our message flow is already predefined for us, so click Cancel, and then Cancel again to return to our project view.
Activating the Echo proxy service
We now have a completed proxy service; all that remains is to commit our work. Within the Change Center click Activate.
This will bring up the Activate Session, as shown in the following screenshot:
Before activating a session, it's good practice to give a description of the changes that we've made, just in case we need to roll them back later. So enter an appropriate description and then click on Submit, as shown in the preceding screenshot:
Assuming everything is okay, this will activate our changes, and the console will be updated to list our configuration changes, as shown in the following screenshot:
If you make a mistake and want to undo the changes you have activated, then you can click on the undo icon (circled in the preceding screenshot), and if you change your mind, you can revert the undo.
OSB allows you to undo any of your previous sessions as long as it doesn't result in an error in the runtime configuration of the Service Bus.
Testing our proxy service
All that's left is to test our proxy service. A simple way to do this is to initiate a test instance using the Service Bus test console.
To do this, we need to navigate back to the definition of our proxy service, rather than do this via the Project Explorer. We will use the Resource Browser. This provides a way to view all resources based on their type.
Click on the Resource Browser section within the navigation bar. By default, it will list all proxy services defined to the Service Bus, as shown in the following screenshot:
We can then filter this list further by specifying the appropriate search criteria.
Click on the Launch Test Console icon for the Echo proxy service (circled in the preceding screenshot). This will launch the test console shown on the next page.
The
Available Operations drop-down list allows us to specify which operation we want to invoke. In our case, it's automatically defaulted to process.
By default, the options Direct Call and Include Tracing are selected within the Test Configuration section; keep these selected as they enable us to trace the state of a message as it passes through the proxy service.
The Request Document section allows us to specify the SOAP Header and the Payload for our service. By default, these will contain a skeleton XML fragment based on the WSDL definition of the selected operation with default values for each field.
To execute a test instance of our service, modify the text in the <echo:input>
element, as we have in the following screen shot, and click Execute. This will cause the console to generate a request message and use it to invoke our Echo proxy service.
Upon successful execution of the proxy, the test console will be updated to show the response returned. Here we can see that the result
element contains our original initial input string, as shown in the following screenshot:
We can examine the state of our message as it passed through the proxy service by expanding the Invocation Trace, as we have in the following screenshot:
In addition, if you log back into the EM console, you should be able to see the Assembly instance that was invoked by the Service Bus.
Creating a Change Session
Before
we can create a new project, or make any configuration changes through the console, we must create a new change session. A Change Session allows us to specify a series of changes as a single unit of work. These changes won't come into effect until we activate a session. At any point we can discard our changes, which will cause OSB to roll back those changes and exit our session.
While making changes through a session, other users can also be making changes under separate sessions. If users create changes that conflict with changes in other sessions, then the Service Bus will flag that as a conflict in the Change Center and neither user will be able to commit their changes until those conflicts have been resolved.
To create a new change session, click on Create in the Change Center. This will update the Change Center to indicate that we are in a session and the user who owns that session. As we are logged in as weblogic, it will be updated to show weblogic session, as shown in the following screenshot:
In addition, you will see that the options available to us in the Change Center have changed to Activate, Discard, and Exit.
Before we can create our Echo proxy service, we must create an OSB project in which to place our resources. Typical resources include WSDL, XSD schemas, XSLT, and XQuery as well as Proxy and Business Services.
Resources can be created directly within our top-level project folder, or we can define a folder structure within our project into which we can place our resources.
Note
From within the same OSB domain, you can reference any resource regardless of which project it is included in.
The Project Explorer is where we create and manage all of this. Click on the Project Explorer section within the navigation bar. This will bring up the Projects view, as shown in the following screenshot:
Here we can see a list of all projects defined in OSB, which at this stage just includes the default project. From here we can also create a new project. Enter a project name, for example Chapter02, as shown in the preceding screenshot, and then click Add Project. This will create a new project and update our list of projects to reflect this.
Creating the project folders
Click on the project name will take us to the Project View, as shown in the screenshot on the next page.
We can see that this splits into three sections. The first section provides some basic details about the project including any references to or from artifacts in other projects as well as an optional description.
The second section lists any folders within the current project folder and provides the option to create additional folders within the project.
The final section lists any resource contained within this folder and provides the option to create additional resource.
We are going to create the project folders BusinessService, ProxyService, and WSDL, into which we will place our various resources. To create the first of these, in the Folders section, enter BusinessService as the folder name (circled in the preceding screenshot) and click on Add Folder. This will create a new folder and updates the list of folders to reflect this.
Once created, follow the same process to create the remaining folders; your list of folders will now look as shown in the preceding screenshot.
Before we
can create either our proxy or business service, we need to define the WSDL on which the service will be based. For this, we are going to use the WSDL of our Echo
BPEL process that we created earlier in this chapter.
Before importing the WSDL, we need to ensure that we are in the right folder within our project. To do this, click on the WSDL folder in our Folders list. On doing this the project view will be updated to show us the content of this folder, which is currently empty. In addition, the project summary section of our project view will be updated to show that we are now within the WSDL
folder, as circled in the following screenshot:
If we look at the Project Explorer in the navigation bar, we can see that it has been updated to show our location within the projects structure. By clicking on any project or folder in here, the console will take us to the project view for that location.
To import the
Echo WSDL into our project, click on the drop-down list next to Create Resource in the Resources section, and select Resources from URL, as shown in the following screenshot:
This will bring
up the page for loading resources from a URL, which is shown in the following screenshot:
Note
A WSDL can also be imported from the filesystem by selecting the WSDL option from the Create Resource drop-down list.
In the URL/Path, enter the URL for our Echo WSDL. This is the WSDL location we made a note of earlier (in the WSDL tab for the Echo process in the BPEL console) and should look like the following:
Enter an appropriate value for the Resource Name(for example Echo), select a Resource Type as WSDL, and click on Next.
This will bring up the Load Resources window, which will list the resources that OSB is ready to import.
You will notice that in addition to the actual WSDL file, it will also list the Echo.xsd. This is because the Echo.wsdl contains the following import statement:
This imports the Echo XML schema, which defines the input and output message of our Echo service. This schema was automatically generated by JDeveloper when we created our Echo process. In order to use our WSDL, we will need to import this schema as well. Because of the unusual URL for the XML Schema, the Service Bus generates its own unique name for the schema.
Click Import, the OSB console will confirm that the resources have been successfully imported and provide the option to Load Another resource, as shown in the following screenshot:
Click on the WSDL folder within the project explorer to return to its project view. This will be updated to include our imported resources, as shown in the following screenshot:
Creating our business service
We are now ready to
create our Echo business service. Click on the Business Service folder within the Project Explorer to go to the project view for this folder.
In the Resources section, click on the drop-down list next to Create Resource and select Business Service. This will bring up the General Configuration page for creating a business service, as shown in the following screenshot:
Here we specify the name of our business service (that is, EchoBS) and an optional description. Next we need to specify the Service Type, as we are creating our service based on a WSDL select WSDL Web Service.
Next, click the Browse button. This will launch a window from where we can select the WSDL for the Business Service, as shown on the next page:
By default, this window will list all WSDL resources that are defined to the Service Bus, though you can restrict the list by defining the search criteria.
In our case, we just have the Echo WSDL, so we click on this. We will now be prompted to select a WSDL definition, as shown in the following screenshot:
Here we need to select which binding or port definition we wish to use for our Business Service, select EchoProcess_pt and click Submit. Bindings provide an abstract interface and do not specify the physical endpoint, requiring additional configuration later. Ports have a physical endpoint and so require no additional configuration.
This will return us to the General Configuration screen with the Service Type updated to show the details of the selected WSDL and port, as shown in the following screenshot:
Then, click on Next. This will take us to the Transport Configuration page, as shown in the following screenshot. Here we need to specify how the business service is to invoke an external service.
As we based our business service on the EchoPort definition, the transport settings are already preconfigured, based on the content of our WSDL file.
Note
If we had based our business service on the EchoBinding definition, then the transport configuration would still have been prepopulated except for the Endpoint URI, which we would need to add manually.
From here, click on Last. This will take us to a summary page of our business service. Click on Save to create our business service.
This will return us to the project view on the Business Service folder and display the message The Service EchoBS was created successfully. If we examine the Resources section, we should see that it now contains our newly created business service.
Creating our proxy service
We are now ready to create our Echo proxy service. Click on the Proxy Service folder within the Project Explorer to go to the project view for this folder.
In the Resources section, click on the drop-down list next to Create Resource and select Proxy Service. This will bring up the General Configuration page for creating a proxy service, as shown in the following screenshot:
You will notice that this looks very similar to the general configuration screen for a business service. So as before, enter the name of our service (that is, Echo) and an optional description.
Next, we need to specify the Service Type. We could do this in exactly the same way as we did for our business service and base it on the Echo WSDL. However, this time we are going to base it on our EchoBS business service. We will see why in a moment.
For the Service Type, select Business Service, as shown in the screenshot, and click Browse…. This will launch the Select Business Service window from where we can search for and select the business service that we want to base our proxy service on.
By default, this window will list all the business services defined to the Service Bus, though you can restrict the list by defining the search criteria.
In our case, we just have the EchoBS, so select this, and click on Submit. This will return us to the General Configuration screen with Service Type updated, as shown in the following screenshot:
From here, click Last. This will take us to a summary page of our proxy service. Click Save to create our proxy service.
This will return us to the project view on the Proxy Service folder and display the message The Service Echo was created successfully.
If we examine the Resources section of our project view, we should see that it now contains our newly created proxy service as shown in the following screenshot:
Once we have created our
proxy service, the next step is to specify how it should handle requests. This is defined in the message flow of the proxy service.
The message flow defines the actions that the proxy service should perform when a request is received such as validating the payload, transforming, or enriching it before routing it to the appropriate business service.
Within the resource section of our project view, click on the Edit Message Flow icon, as circled in the preceding image. This will take us to the Edit Message Flow window, where we can view and edit the message flow of our proxy service, as shown in the following screenshot:
Looking at this, we can see that Echo already invokes the route node RouteTo_EchoBS.
Click on this and select Edit Route(as shown in the preceding screenshot). This will take us to the Edit Stage Configuration window, as shown in the following screenshot:
Here we can see that it's already configured to route requests to the EchoBS business service.
Normally, when we create a proxy service we have to specify the message flow from scratch. However, when we created our Echo proxy service we based it on the EchoBS business service (as opposed to a WSDL). Because of this, the Service Bus has automatically configured the message flow to route requests to EchoBS.
As a result, our message flow is already predefined for us, so click Cancel, and then Cancel again to return to our project view.
Activating the Echo proxy service
We now have a completed proxy service; all that remains is to commit our work. Within the Change Center click Activate.
This will bring up the Activate Session, as shown in the following screenshot:
Before activating a session, it's good practice to give a description of the changes that we've made, just in case we need to roll them back later. So enter an appropriate description and then click on Submit, as shown in the preceding screenshot:
Assuming everything is okay, this will activate our changes, and the console will be updated to list our configuration changes, as shown in the following screenshot:
If you make a mistake and want to undo the changes you have activated, then you can click on the undo icon (circled in the preceding screenshot), and if you change your mind, you can revert the undo.
OSB allows you to undo any of your previous sessions as long as it doesn't result in an error in the runtime configuration of the Service Bus.
Testing our proxy service
All that's left is to test our proxy service. A simple way to do this is to initiate a test instance using the Service Bus test console.
To do this, we need to navigate back to the definition of our proxy service, rather than do this via the Project Explorer. We will use the Resource Browser. This provides a way to view all resources based on their type.
Click on the Resource Browser section within the navigation bar. By default, it will list all proxy services defined to the Service Bus, as shown in the following screenshot:
We can then filter this list further by specifying the appropriate search criteria.
Click on the Launch Test Console icon for the Echo proxy service (circled in the preceding screenshot). This will launch the test console shown on the next page.
The
Available Operations drop-down list allows us to specify which operation we want to invoke. In our case, it's automatically defaulted to process.
By default, the options Direct Call and Include Tracing are selected within the Test Configuration section; keep these selected as they enable us to trace the state of a message as it passes through the proxy service.
The Request Document section allows us to specify the SOAP Header and the Payload for our service. By default, these will contain a skeleton XML fragment based on the WSDL definition of the selected operation with default values for each field.
To execute a test instance of our service, modify the text in the <echo:input>
element, as we have in the following screen shot, and click Execute. This will cause the console to generate a request message and use it to invoke our Echo proxy service.
Upon successful execution of the proxy, the test console will be updated to show the response returned. Here we can see that the result
element contains our original initial input string, as shown in the following screenshot:
We can examine the state of our message as it passed through the proxy service by expanding the Invocation Trace, as we have in the following screenshot:
In addition, if you log back into the EM console, you should be able to see the Assembly instance that was invoked by the Service Bus.
Before we can create our Echo proxy service, we must create an OSB project in which to place our resources. Typical resources include WSDL, XSD schemas, XSLT, and XQuery as well as Proxy and Business Services.
Resources can be created directly within our top-level project folder, or we can define a folder structure within our project into which we can place our resources.
Note
From within the same OSB domain, you can reference any resource regardless of which project it is included in.
The Project Explorer is where we create and manage all of this. Click on the Project Explorer section within the navigation bar. This will bring up the Projects view, as shown in the following screenshot:
Here we can see a list of all projects defined in OSB, which at this stage just includes the default project. From here we can also create a new project. Enter a project name, for example Chapter02, as shown in the preceding screenshot, and then click Add Project. This will create a new project and update our list of projects to reflect this.
Creating the project folders
Click on the project name will take us to the Project View, as shown in the screenshot on the next page.
We can see that this splits into three sections. The first section provides some basic details about the project including any references to or from artifacts in other projects as well as an optional description.
The second section lists any folders within the current project folder and provides the option to create additional folders within the project.
The final section lists any resource contained within this folder and provides the option to create additional resource.
We are going to create the project folders BusinessService, ProxyService, and WSDL, into which we will place our various resources. To create the first of these, in the Folders section, enter BusinessService as the folder name (circled in the preceding screenshot) and click on Add Folder. This will create a new folder and updates the list of folders to reflect this.
Once created, follow the same process to create the remaining folders; your list of folders will now look as shown in the preceding screenshot.
Before we
can create either our proxy or business service, we need to define the WSDL on which the service will be based. For this, we are going to use the WSDL of our Echo
BPEL process that we created earlier in this chapter.
Before importing the WSDL, we need to ensure that we are in the right folder within our project. To do this, click on the WSDL folder in our Folders list. On doing this the project view will be updated to show us the content of this folder, which is currently empty. In addition, the project summary section of our project view will be updated to show that we are now within the WSDL
folder, as circled in the following screenshot:
If we look at the Project Explorer in the navigation bar, we can see that it has been updated to show our location within the projects structure. By clicking on any project or folder in here, the console will take us to the project view for that location.
To import the
Echo WSDL into our project, click on the drop-down list next to Create Resource in the Resources section, and select Resources from URL, as shown in the following screenshot:
This will bring
up the page for loading resources from a URL, which is shown in the following screenshot:
Note
A WSDL can also be imported from the filesystem by selecting the WSDL option from the Create Resource drop-down list.
In the URL/Path, enter the URL for our Echo WSDL. This is the WSDL location we made a note of earlier (in the WSDL tab for the Echo process in the BPEL console) and should look like the following:
Enter an appropriate value for the Resource Name(for example Echo), select a Resource Type as WSDL, and click on Next.
This will bring up the Load Resources window, which will list the resources that OSB is ready to import.
You will notice that in addition to the actual WSDL file, it will also list the Echo.xsd. This is because the Echo.wsdl contains the following import statement:
This imports the Echo XML schema, which defines the input and output message of our Echo service. This schema was automatically generated by JDeveloper when we created our Echo process. In order to use our WSDL, we will need to import this schema as well. Because of the unusual URL for the XML Schema, the Service Bus generates its own unique name for the schema.
Click Import, the OSB console will confirm that the resources have been successfully imported and provide the option to Load Another resource, as shown in the following screenshot:
Click on the WSDL folder within the project explorer to return to its project view. This will be updated to include our imported resources, as shown in the following screenshot:
Creating our business service
We are now ready to
create our Echo business service. Click on the Business Service folder within the Project Explorer to go to the project view for this folder.
In the Resources section, click on the drop-down list next to Create Resource and select Business Service. This will bring up the General Configuration page for creating a business service, as shown in the following screenshot:
Here we specify the name of our business service (that is, EchoBS) and an optional description. Next we need to specify the Service Type, as we are creating our service based on a WSDL select WSDL Web Service.
Next, click the Browse button. This will launch a window from where we can select the WSDL for the Business Service, as shown on the next page:
By default, this window will list all WSDL resources that are defined to the Service Bus, though you can restrict the list by defining the search criteria.
In our case, we just have the Echo WSDL, so we click on this. We will now be prompted to select a WSDL definition, as shown in the following screenshot:
Here we need to select which binding or port definition we wish to use for our Business Service, select EchoProcess_pt and click Submit. Bindings provide an abstract interface and do not specify the physical endpoint, requiring additional configuration later. Ports have a physical endpoint and so require no additional configuration.
This will return us to the General Configuration screen with the Service Type updated to show the details of the selected WSDL and port, as shown in the following screenshot:
Then, click on Next. This will take us to the Transport Configuration page, as shown in the following screenshot. Here we need to specify how the business service is to invoke an external service.
As we based our business service on the EchoPort definition, the transport settings are already preconfigured, based on the content of our WSDL file.
Note
If we had based our business service on the EchoBinding definition, then the transport configuration would still have been prepopulated except for the Endpoint URI, which we would need to add manually.
From here, click on Last. This will take us to a summary page of our business service. Click on Save to create our business service.
This will return us to the project view on the Business Service folder and display the message The Service EchoBS was created successfully. If we examine the Resources section, we should see that it now contains our newly created business service.
Creating our proxy service
We are now ready to create our Echo proxy service. Click on the Proxy Service folder within the Project Explorer to go to the project view for this folder.
In the Resources section, click on the drop-down list next to Create Resource and select Proxy Service. This will bring up the General Configuration page for creating a proxy service, as shown in the following screenshot:
You will notice that this looks very similar to the general configuration screen for a business service. So as before, enter the name of our service (that is, Echo) and an optional description.
Next, we need to specify the Service Type. We could do this in exactly the same way as we did for our business service and base it on the Echo WSDL. However, this time we are going to base it on our EchoBS business service. We will see why in a moment.
For the Service Type, select Business Service, as shown in the screenshot, and click Browse…. This will launch the Select Business Service window from where we can search for and select the business service that we want to base our proxy service on.
By default, this window will list all the business services defined to the Service Bus, though you can restrict the list by defining the search criteria.
In our case, we just have the EchoBS, so select this, and click on Submit. This will return us to the General Configuration screen with Service Type updated, as shown in the following screenshot:
From here, click Last. This will take us to a summary page of our proxy service. Click Save to create our proxy service.
This will return us to the project view on the Proxy Service folder and display the message The Service Echo was created successfully.
If we examine the Resources section of our project view, we should see that it now contains our newly created proxy service as shown in the following screenshot:
Once we have created our
proxy service, the next step is to specify how it should handle requests. This is defined in the message flow of the proxy service.
The message flow defines the actions that the proxy service should perform when a request is received such as validating the payload, transforming, or enriching it before routing it to the appropriate business service.
Within the resource section of our project view, click on the Edit Message Flow icon, as circled in the preceding image. This will take us to the Edit Message Flow window, where we can view and edit the message flow of our proxy service, as shown in the following screenshot:
Looking at this, we can see that Echo already invokes the route node RouteTo_EchoBS.
Click on this and select Edit Route(as shown in the preceding screenshot). This will take us to the Edit Stage Configuration window, as shown in the following screenshot:
Here we can see that it's already configured to route requests to the EchoBS business service.
Normally, when we create a proxy service we have to specify the message flow from scratch. However, when we created our Echo proxy service we based it on the EchoBS business service (as opposed to a WSDL). Because of this, the Service Bus has automatically configured the message flow to route requests to EchoBS.
As a result, our message flow is already predefined for us, so click Cancel, and then Cancel again to return to our project view.
Activating the Echo proxy service
We now have a completed proxy service; all that remains is to commit our work. Within the Change Center click Activate.
This will bring up the Activate Session, as shown in the following screenshot:
Before activating a session, it's good practice to give a description of the changes that we've made, just in case we need to roll them back later. So enter an appropriate description and then click on Submit, as shown in the preceding screenshot:
Assuming everything is okay, this will activate our changes, and the console will be updated to list our configuration changes, as shown in the following screenshot:
If you make a mistake and want to undo the changes you have activated, then you can click on the undo icon (circled in the preceding screenshot), and if you change your mind, you can revert the undo.
OSB allows you to undo any of your previous sessions as long as it doesn't result in an error in the runtime configuration of the Service Bus.
Testing our proxy service
All that's left is to test our proxy service. A simple way to do this is to initiate a test instance using the Service Bus test console.
To do this, we need to navigate back to the definition of our proxy service, rather than do this via the Project Explorer. We will use the Resource Browser. This provides a way to view all resources based on their type.
Click on the Resource Browser section within the navigation bar. By default, it will list all proxy services defined to the Service Bus, as shown in the following screenshot:
We can then filter this list further by specifying the appropriate search criteria.
Click on the Launch Test Console icon for the Echo proxy service (circled in the preceding screenshot). This will launch the test console shown on the next page.
The
Available Operations drop-down list allows us to specify which operation we want to invoke. In our case, it's automatically defaulted to process.
By default, the options Direct Call and Include Tracing are selected within the Test Configuration section; keep these selected as they enable us to trace the state of a message as it passes through the proxy service.
The Request Document section allows us to specify the SOAP Header and the Payload for our service. By default, these will contain a skeleton XML fragment based on the WSDL definition of the selected operation with default values for each field.
To execute a test instance of our service, modify the text in the <echo:input>
element, as we have in the following screen shot, and click Execute. This will cause the console to generate a request message and use it to invoke our Echo proxy service.
Upon successful execution of the proxy, the test console will be updated to show the response returned. Here we can see that the result
element contains our original initial input string, as shown in the following screenshot:
We can examine the state of our message as it passed through the proxy service by expanding the Invocation Trace, as we have in the following screenshot:
In addition, if you log back into the EM console, you should be able to see the Assembly instance that was invoked by the Service Bus.
Creating the project folders
Click on the project name will take us to the Project View, as shown in the screenshot on the next page.
We can see that this splits into three sections. The first section provides some basic details about the project including any references to or from artifacts in other projects as well as an optional description.
The second section lists any folders within the current project folder and provides the option to create additional folders within the project.
The final section lists any resource contained within this folder and provides the option to create additional resource.
We are going to create the project folders BusinessService, ProxyService, and WSDL, into which we will place our various resources. To create the first of these, in the Folders section, enter BusinessService as the folder name (circled in the preceding screenshot) and click on Add Folder. This will create a new folder and updates the list of folders to reflect this.
Once created, follow the same process to create the remaining folders; your list of folders will now look as shown in the preceding screenshot.
Before we
can create either our proxy or business service, we need to define the WSDL on which the service will be based. For this, we are going to use the WSDL of our Echo
BPEL process that we created earlier in this chapter.
Before importing the WSDL, we need to ensure that we are in the right folder within our project. To do this, click on the WSDL folder in our Folders list. On doing this the project view will be updated to show us the content of this folder, which is currently empty. In addition, the project summary section of our project view will be updated to show that we are now within the WSDL
folder, as circled in the following screenshot:
If we look at the Project Explorer in the navigation bar, we can see that it has been updated to show our location within the projects structure. By clicking on any project or folder in here, the console will take us to the project view for that location.
To import the
Echo WSDL into our project, click on the drop-down list next to Create Resource in the Resources section, and select Resources from URL, as shown in the following screenshot:
This will bring
up the page for loading resources from a URL, which is shown in the following screenshot:
Note
A WSDL can also be imported from the filesystem by selecting the WSDL option from the Create Resource drop-down list.
In the URL/Path, enter the URL for our Echo WSDL. This is the WSDL location we made a note of earlier (in the WSDL tab for the Echo process in the BPEL console) and should look like the following:
Enter an appropriate value for the Resource Name(for example Echo), select a Resource Type as WSDL, and click on Next.
This will bring up the Load Resources window, which will list the resources that OSB is ready to import.
You will notice that in addition to the actual WSDL file, it will also list the Echo.xsd. This is because the Echo.wsdl contains the following import statement:
This imports the Echo XML schema, which defines the input and output message of our Echo service. This schema was automatically generated by JDeveloper when we created our Echo process. In order to use our WSDL, we will need to import this schema as well. Because of the unusual URL for the XML Schema, the Service Bus generates its own unique name for the schema.
Click Import, the OSB console will confirm that the resources have been successfully imported and provide the option to Load Another resource, as shown in the following screenshot:
Click on the WSDL folder within the project explorer to return to its project view. This will be updated to include our imported resources, as shown in the following screenshot:
Creating our business service We are now ready to
create our Echo business service. Click on the Business Service folder within the Project Explorer to go to the project view for this folder.
In the Resources section, click on the drop-down list next to Create Resource and select Business Service. This will bring up the General Configuration page for creating a business service, as shown in the following screenshot:
Here we specify the name of our business service (that is, EchoBS) and an optional description. Next we need to specify the Service Type, as we are creating our service based on a WSDL select WSDL Web Service.
Next, click the Browse button. This will launch a window from where we can select the WSDL for the Business Service, as shown on the next page:
By default, this window will list all WSDL resources that are defined to the Service Bus, though you can restrict the list by defining the search criteria.
In our case, we just have the Echo WSDL, so we click on this. We will now be prompted to select a WSDL definition, as shown in the following screenshot:
Here we need to select which binding or port definition we wish to use for our Business Service, select EchoProcess_pt and click Submit. Bindings provide an abstract interface and do not specify the physical endpoint, requiring additional configuration later. Ports have a physical endpoint and so require no additional configuration.
This will return us to the General Configuration screen with the Service Type updated to show the details of the selected WSDL and port, as shown in the following screenshot:
Then, click on Next. This will take us to the Transport Configuration page, as shown in the following screenshot. Here we need to specify how the business service is to invoke an external service.
As we based our business service on the EchoPort definition, the transport settings are already preconfigured, based on the content of our WSDL file.
Note
If we had based our business service on the EchoBinding definition, then the transport configuration would still have been prepopulated except for the Endpoint URI, which we would need to add manually.
From here, click on Last. This will take us to a summary page of our business service. Click on Save to create our business service.
This will return us to the project view on the Business Service folder and display the message The Service EchoBS was created successfully. If we examine the Resources section, we should see that it now contains our newly created business service.
Creating our proxy service We are now ready to create our Echo proxy service. Click on the Proxy Service folder within the Project Explorer to go to the project view for this folder.
In the Resources section, click on the drop-down list next to Create Resource and select Proxy Service. This will bring up the General Configuration page for creating a proxy service, as shown in the following screenshot:
You will notice that this looks very similar to the general configuration screen for a business service. So as before, enter the name of our service (that is, Echo) and an optional description.
Next, we need to specify the Service Type. We could do this in exactly the same way as we did for our business service and base it on the Echo WSDL. However, this time we are going to base it on our EchoBS business service. We will see why in a moment.
For the Service Type, select Business Service, as shown in the screenshot, and click Browse…. This will launch the Select Business Service window from where we can search for and select the business service that we want to base our proxy service on.
By default, this window will list all the business services defined to the Service Bus, though you can restrict the list by defining the search criteria.
In our case, we just have the EchoBS, so select this, and click on Submit. This will return us to the General Configuration screen with Service Type updated, as shown in the following screenshot:
From here, click Last. This will take us to a summary page of our proxy service. Click Save to create our proxy service.
This will return us to the project view on the Proxy Service folder and display the message The Service Echo was created successfully.
If we examine the Resources section of our project view, we should see that it now contains our newly created proxy service as shown in the following screenshot:
Once we have created our
proxy service, the next step is to specify how it should handle requests. This is defined in the message flow of the proxy service.
The message flow defines the actions that the proxy service should perform when a request is received such as validating the payload, transforming, or enriching it before routing it to the appropriate business service.
Within the resource section of our project view, click on the Edit Message Flow icon, as circled in the preceding image. This will take us to the Edit Message Flow window, where we can view and edit the message flow of our proxy service, as shown in the following screenshot:
Looking at this, we can see that Echo already invokes the route node RouteTo_EchoBS.
Click on this and select Edit Route(as shown in the preceding screenshot). This will take us to the Edit Stage Configuration window, as shown in the following screenshot:
Here we can see that it's already configured to route requests to the EchoBS business service.
Normally, when we create a proxy service we have to specify the message flow from scratch. However, when we created our Echo proxy service we based it on the EchoBS business service (as opposed to a WSDL). Because of this, the Service Bus has automatically configured the message flow to route requests to EchoBS.
As a result, our message flow is already predefined for us, so click Cancel, and then Cancel again to return to our project view.
Activating the Echo proxy service
We now have a completed proxy service; all that remains is to commit our work. Within the Change Center click Activate.
This will bring up the Activate Session, as shown in the following screenshot:
Before activating a session, it's good practice to give a description of the changes that we've made, just in case we need to roll them back later. So enter an appropriate description and then click on Submit, as shown in the preceding screenshot:
Assuming everything is okay, this will activate our changes, and the console will be updated to list our configuration changes, as shown in the following screenshot:
If you make a mistake and want to undo the changes you have activated, then you can click on the undo icon (circled in the preceding screenshot), and if you change your mind, you can revert the undo.
OSB allows you to undo any of your previous sessions as long as it doesn't result in an error in the runtime configuration of the Service Bus.
Testing our proxy service
All that's left is to test our proxy service. A simple way to do this is to initiate a test instance using the Service Bus test console.
To do this, we need to navigate back to the definition of our proxy service, rather than do this via the Project Explorer. We will use the Resource Browser. This provides a way to view all resources based on their type.
Click on the Resource Browser section within the navigation bar. By default, it will list all proxy services defined to the Service Bus, as shown in the following screenshot:
We can then filter this list further by specifying the appropriate search criteria.
Click on the Launch Test Console icon for the Echo proxy service (circled in the preceding screenshot). This will launch the test console shown on the next page.
The
Available Operations drop-down list allows us to specify which operation we want to invoke. In our case, it's automatically defaulted to process.
By default, the options Direct Call and Include Tracing are selected within the Test Configuration section; keep these selected as they enable us to trace the state of a message as it passes through the proxy service.
The Request Document section allows us to specify the SOAP Header and the Payload for our service. By default, these will contain a skeleton XML fragment based on the WSDL definition of the selected operation with default values for each field.
To execute a test instance of our service, modify the text in the <echo:input>
element, as we have in the following screen shot, and click Execute. This will cause the console to generate a request message and use it to invoke our Echo proxy service.
Upon successful execution of the proxy, the test console will be updated to show the response returned. Here we can see that the result
element contains our original initial input string, as shown in the following screenshot:
We can examine the state of our message as it passed through the proxy service by expanding the Invocation Trace, as we have in the following screenshot:
In addition, if you log back into the EM console, you should be able to see the Assembly instance that was invoked by the Service Bus.
Before we
can create either our proxy or business service, we need to define the WSDL on which the service will be based. For this, we are going to use the WSDL of our Echo
BPEL process that we created earlier in this chapter.
Before importing the WSDL, we need to ensure that we are in the right folder within our project. To do this, click on the WSDL folder in our Folders list. On doing this the project view will be updated to show us the content of this folder, which is currently empty. In addition, the project summary section of our project view will be updated to show that we are now within the WSDL
folder, as circled in the following screenshot:
If we look at the Project Explorer in the navigation bar, we can see that it has been updated to show our location within the projects structure. By clicking on any project or folder in here, the console will take us to the project view for that location.
To import the
Echo WSDL into our project, click on the drop-down list next to Create Resource in the Resources section, and select Resources from URL, as shown in the following screenshot:
This will bring
up the page for loading resources from a URL, which is shown in the following screenshot:
Note
A WSDL can also be imported from the filesystem by selecting the WSDL option from the Create Resource drop-down list.
In the URL/Path, enter the URL for our Echo WSDL. This is the WSDL location we made a note of earlier (in the WSDL tab for the Echo process in the BPEL console) and should look like the following:
Enter an appropriate value for the Resource Name(for example Echo), select a Resource Type as WSDL, and click on Next.
This will bring up the Load Resources window, which will list the resources that OSB is ready to import.
You will notice that in addition to the actual WSDL file, it will also list the Echo.xsd. This is because the Echo.wsdl contains the following import statement:
This imports the Echo XML schema, which defines the input and output message of our Echo service. This schema was automatically generated by JDeveloper when we created our Echo process. In order to use our WSDL, we will need to import this schema as well. Because of the unusual URL for the XML Schema, the Service Bus generates its own unique name for the schema.
Click Import, the OSB console will confirm that the resources have been successfully imported and provide the option to Load Another resource, as shown in the following screenshot:
Click on the WSDL folder within the project explorer to return to its project view. This will be updated to include our imported resources, as shown in the following screenshot:
Creating our business service
We are now ready to
create our Echo business service. Click on the Business Service folder within the Project Explorer to go to the project view for this folder.
In the Resources section, click on the drop-down list next to Create Resource and select Business Service. This will bring up the General Configuration page for creating a business service, as shown in the following screenshot:
Here we specify the name of our business service (that is, EchoBS) and an optional description. Next we need to specify the Service Type, as we are creating our service based on a WSDL select WSDL Web Service.
Next, click the Browse button. This will launch a window from where we can select the WSDL for the Business Service, as shown on the next page:
By default, this window will list all WSDL resources that are defined to the Service Bus, though you can restrict the list by defining the search criteria.
In our case, we just have the Echo WSDL, so we click on this. We will now be prompted to select a WSDL definition, as shown in the following screenshot:
Here we need to select which binding or port definition we wish to use for our Business Service, select EchoProcess_pt and click Submit. Bindings provide an abstract interface and do not specify the physical endpoint, requiring additional configuration later. Ports have a physical endpoint and so require no additional configuration.
This will return us to the General Configuration screen with the Service Type updated to show the details of the selected WSDL and port, as shown in the following screenshot:
Then, click on Next. This will take us to the Transport Configuration page, as shown in the following screenshot. Here we need to specify how the business service is to invoke an external service.
As we based our business service on the EchoPort definition, the transport settings are already preconfigured, based on the content of our WSDL file.
Note
If we had based our business service on the EchoBinding definition, then the transport configuration would still have been prepopulated except for the Endpoint URI, which we would need to add manually.
From here, click on Last. This will take us to a summary page of our business service. Click on Save to create our business service.
This will return us to the project view on the Business Service folder and display the message The Service EchoBS was created successfully. If we examine the Resources section, we should see that it now contains our newly created business service.
Creating our proxy service
We are now ready to create our Echo proxy service. Click on the Proxy Service folder within the Project Explorer to go to the project view for this folder.
In the Resources section, click on the drop-down list next to Create Resource and select Proxy Service. This will bring up the General Configuration page for creating a proxy service, as shown in the following screenshot:
You will notice that this looks very similar to the general configuration screen for a business service. So as before, enter the name of our service (that is, Echo) and an optional description.
Next, we need to specify the Service Type. We could do this in exactly the same way as we did for our business service and base it on the Echo WSDL. However, this time we are going to base it on our EchoBS business service. We will see why in a moment.
For the Service Type, select Business Service, as shown in the screenshot, and click Browse…. This will launch the Select Business Service window from where we can search for and select the business service that we want to base our proxy service on.
By default, this window will list all the business services defined to the Service Bus, though you can restrict the list by defining the search criteria.
In our case, we just have the EchoBS, so select this, and click on Submit. This will return us to the General Configuration screen with Service Type updated, as shown in the following screenshot:
From here, click Last. This will take us to a summary page of our proxy service. Click Save to create our proxy service.
This will return us to the project view on the Proxy Service folder and display the message The Service Echo was created successfully.
If we examine the Resources section of our project view, we should see that it now contains our newly created proxy service as shown in the following screenshot:
Once we have created our
proxy service, the next step is to specify how it should handle requests. This is defined in the message flow of the proxy service.
The message flow defines the actions that the proxy service should perform when a request is received such as validating the payload, transforming, or enriching it before routing it to the appropriate business service.
Within the resource section of our project view, click on the Edit Message Flow icon, as circled in the preceding image. This will take us to the Edit Message Flow window, where we can view and edit the message flow of our proxy service, as shown in the following screenshot:
Looking at this, we can see that Echo already invokes the route node RouteTo_EchoBS.
Click on this and select Edit Route(as shown in the preceding screenshot). This will take us to the Edit Stage Configuration window, as shown in the following screenshot:
Here we can see that it's already configured to route requests to the EchoBS business service.
Normally, when we create a proxy service we have to specify the message flow from scratch. However, when we created our Echo proxy service we based it on the EchoBS business service (as opposed to a WSDL). Because of this, the Service Bus has automatically configured the message flow to route requests to EchoBS.
As a result, our message flow is already predefined for us, so click Cancel, and then Cancel again to return to our project view.
Activating the Echo proxy service
We now have a completed proxy service; all that remains is to commit our work. Within the Change Center click Activate.
This will bring up the Activate Session, as shown in the following screenshot:
Before activating a session, it's good practice to give a description of the changes that we've made, just in case we need to roll them back later. So enter an appropriate description and then click on Submit, as shown in the preceding screenshot:
Assuming everything is okay, this will activate our changes, and the console will be updated to list our configuration changes, as shown in the following screenshot:
If you make a mistake and want to undo the changes you have activated, then you can click on the undo icon (circled in the preceding screenshot), and if you change your mind, you can revert the undo.
OSB allows you to undo any of your previous sessions as long as it doesn't result in an error in the runtime configuration of the Service Bus.
Testing our proxy service
All that's left is to test our proxy service. A simple way to do this is to initiate a test instance using the Service Bus test console.
To do this, we need to navigate back to the definition of our proxy service, rather than do this via the Project Explorer. We will use the Resource Browser. This provides a way to view all resources based on their type.
Click on the Resource Browser section within the navigation bar. By default, it will list all proxy services defined to the Service Bus, as shown in the following screenshot:
We can then filter this list further by specifying the appropriate search criteria.
Click on the Launch Test Console icon for the Echo proxy service (circled in the preceding screenshot). This will launch the test console shown on the next page.
The
Available Operations drop-down list allows us to specify which operation we want to invoke. In our case, it's automatically defaulted to process.
By default, the options Direct Call and Include Tracing are selected within the Test Configuration section; keep these selected as they enable us to trace the state of a message as it passes through the proxy service.
The Request Document section allows us to specify the SOAP Header and the Payload for our service. By default, these will contain a skeleton XML fragment based on the WSDL definition of the selected operation with default values for each field.
To execute a test instance of our service, modify the text in the <echo:input>
element, as we have in the following screen shot, and click Execute. This will cause the console to generate a request message and use it to invoke our Echo proxy service.
Upon successful execution of the proxy, the test console will be updated to show the response returned. Here we can see that the result
element contains our original initial input string, as shown in the following screenshot:
We can examine the state of our message as it passed through the proxy service by expanding the Invocation Trace, as we have in the following screenshot:
In addition, if you log back into the EM console, you should be able to see the Assembly instance that was invoked by the Service Bus.
To import the
Echo WSDL into our project, click on the drop-down list next to Create Resource in the Resources section, and select Resources from URL, as shown in the following screenshot:
This will bring
up the page for loading resources from a URL, which is shown in the following screenshot:
Note
A WSDL can also be imported from the filesystem by selecting the WSDL option from the Create Resource drop-down list.
In the URL/Path, enter the URL for our Echo WSDL. This is the WSDL location we made a note of earlier (in the WSDL tab for the Echo process in the BPEL console) and should look like the following:
Enter an appropriate value for the Resource Name(for example Echo), select a Resource Type as WSDL, and click on Next.
This will bring up the Load Resources window, which will list the resources that OSB is ready to import.
You will notice that in addition to the actual WSDL file, it will also list the Echo.xsd. This is because the Echo.wsdl contains the following import statement:
This imports the Echo XML schema, which defines the input and output message of our Echo service. This schema was automatically generated by JDeveloper when we created our Echo process. In order to use our WSDL, we will need to import this schema as well. Because of the unusual URL for the XML Schema, the Service Bus generates its own unique name for the schema.
Click Import, the OSB console will confirm that the resources have been successfully imported and provide the option to Load Another resource, as shown in the following screenshot:
Click on the WSDL folder within the project explorer to return to its project view. This will be updated to include our imported resources, as shown in the following screenshot:
Creating our business service We are now ready to
create our Echo business service. Click on the Business Service folder within the Project Explorer to go to the project view for this folder.
In the Resources section, click on the drop-down list next to Create Resource and select Business Service. This will bring up the General Configuration page for creating a business service, as shown in the following screenshot:
Here we specify the name of our business service (that is, EchoBS) and an optional description. Next we need to specify the Service Type, as we are creating our service based on a WSDL select WSDL Web Service.
Next, click the Browse button. This will launch a window from where we can select the WSDL for the Business Service, as shown on the next page:
By default, this window will list all WSDL resources that are defined to the Service Bus, though you can restrict the list by defining the search criteria.
In our case, we just have the Echo WSDL, so we click on this. We will now be prompted to select a WSDL definition, as shown in the following screenshot:
Here we need to select which binding or port definition we wish to use for our Business Service, select EchoProcess_pt and click Submit. Bindings provide an abstract interface and do not specify the physical endpoint, requiring additional configuration later. Ports have a physical endpoint and so require no additional configuration.
This will return us to the General Configuration screen with the Service Type updated to show the details of the selected WSDL and port, as shown in the following screenshot:
Then, click on Next. This will take us to the Transport Configuration page, as shown in the following screenshot. Here we need to specify how the business service is to invoke an external service.
As we based our business service on the EchoPort definition, the transport settings are already preconfigured, based on the content of our WSDL file.
Note
If we had based our business service on the EchoBinding definition, then the transport configuration would still have been prepopulated except for the Endpoint URI, which we would need to add manually.
From here, click on Last. This will take us to a summary page of our business service. Click on Save to create our business service.
This will return us to the project view on the Business Service folder and display the message The Service EchoBS was created successfully. If we examine the Resources section, we should see that it now contains our newly created business service.
Creating our proxy service We are now ready to create our Echo proxy service. Click on the Proxy Service folder within the Project Explorer to go to the project view for this folder.
In the Resources section, click on the drop-down list next to Create Resource and select Proxy Service. This will bring up the General Configuration page for creating a proxy service, as shown in the following screenshot:
You will notice that this looks very similar to the general configuration screen for a business service. So as before, enter the name of our service (that is, Echo) and an optional description.
Next, we need to specify the Service Type. We could do this in exactly the same way as we did for our business service and base it on the Echo WSDL. However, this time we are going to base it on our EchoBS business service. We will see why in a moment.
For the Service Type, select Business Service, as shown in the screenshot, and click Browse…. This will launch the Select Business Service window from where we can search for and select the business service that we want to base our proxy service on.
By default, this window will list all the business services defined to the Service Bus, though you can restrict the list by defining the search criteria.
In our case, we just have the EchoBS, so select this, and click on Submit. This will return us to the General Configuration screen with Service Type updated, as shown in the following screenshot:
From here, click Last. This will take us to a summary page of our proxy service. Click Save to create our proxy service.
This will return us to the project view on the Proxy Service folder and display the message The Service Echo was created successfully.
If we examine the Resources section of our project view, we should see that it now contains our newly created proxy service as shown in the following screenshot:
Once we have created our
proxy service, the next step is to specify how it should handle requests. This is defined in the message flow of the proxy service.
The message flow defines the actions that the proxy service should perform when a request is received such as validating the payload, transforming, or enriching it before routing it to the appropriate business service.
Within the resource section of our project view, click on the Edit Message Flow icon, as circled in the preceding image. This will take us to the Edit Message Flow window, where we can view and edit the message flow of our proxy service, as shown in the following screenshot:
Looking at this, we can see that Echo already invokes the route node RouteTo_EchoBS.
Click on this and select Edit Route(as shown in the preceding screenshot). This will take us to the Edit Stage Configuration window, as shown in the following screenshot:
Here we can see that it's already configured to route requests to the EchoBS business service.
Normally, when we create a proxy service we have to specify the message flow from scratch. However, when we created our Echo proxy service we based it on the EchoBS business service (as opposed to a WSDL). Because of this, the Service Bus has automatically configured the message flow to route requests to EchoBS.
As a result, our message flow is already predefined for us, so click Cancel, and then Cancel again to return to our project view.
Activating the Echo proxy service
We now have a completed proxy service; all that remains is to commit our work. Within the Change Center click Activate.
This will bring up the Activate Session, as shown in the following screenshot:
Before activating a session, it's good practice to give a description of the changes that we've made, just in case we need to roll them back later. So enter an appropriate description and then click on Submit, as shown in the preceding screenshot:
Assuming everything is okay, this will activate our changes, and the console will be updated to list our configuration changes, as shown in the following screenshot:
If you make a mistake and want to undo the changes you have activated, then you can click on the undo icon (circled in the preceding screenshot), and if you change your mind, you can revert the undo.
OSB allows you to undo any of your previous sessions as long as it doesn't result in an error in the runtime configuration of the Service Bus.
Testing our proxy service
All that's left is to test our proxy service. A simple way to do this is to initiate a test instance using the Service Bus test console.
To do this, we need to navigate back to the definition of our proxy service, rather than do this via the Project Explorer. We will use the Resource Browser. This provides a way to view all resources based on their type.
Click on the Resource Browser section within the navigation bar. By default, it will list all proxy services defined to the Service Bus, as shown in the following screenshot:
We can then filter this list further by specifying the appropriate search criteria.
Click on the Launch Test Console icon for the Echo proxy service (circled in the preceding screenshot). This will launch the test console shown on the next page.
The
Available Operations drop-down list allows us to specify which operation we want to invoke. In our case, it's automatically defaulted to process.
By default, the options Direct Call and Include Tracing are selected within the Test Configuration section; keep these selected as they enable us to trace the state of a message as it passes through the proxy service.
The Request Document section allows us to specify the SOAP Header and the Payload for our service. By default, these will contain a skeleton XML fragment based on the WSDL definition of the selected operation with default values for each field.
To execute a test instance of our service, modify the text in the <echo:input>
element, as we have in the following screen shot, and click Execute. This will cause the console to generate a request message and use it to invoke our Echo proxy service.
Upon successful execution of the proxy, the test console will be updated to show the response returned. Here we can see that the result
element contains our original initial input string, as shown in the following screenshot:
We can examine the state of our message as it passed through the proxy service by expanding the Invocation Trace, as we have in the following screenshot:
In addition, if you log back into the EM console, you should be able to see the Assembly instance that was invoked by the Service Bus.
Creating our business service
We are now ready to
create our Echo business service. Click on the Business Service folder within the Project Explorer to go to the project view for this folder.
In the Resources section, click on the drop-down list next to Create Resource and select Business Service. This will bring up the General Configuration page for creating a business service, as shown in the following screenshot:
Here we specify the name of our business service (that is, EchoBS) and an optional description. Next we need to specify the Service Type, as we are creating our service based on a WSDL select WSDL Web Service.
Next, click the Browse button. This will launch a window from where we can select the WSDL for the Business Service, as shown on the next page:
By default, this window will list all WSDL resources that are defined to the Service Bus, though you can restrict the list by defining the search criteria.
In our case, we just have the Echo WSDL, so we click on this. We will now be prompted to select a WSDL definition, as shown in the following screenshot:
Here we need to select which binding or port definition we wish to use for our Business Service, select EchoProcess_pt and click Submit. Bindings provide an abstract interface and do not specify the physical endpoint, requiring additional configuration later. Ports have a physical endpoint and so require no additional configuration.
This will return us to the General Configuration screen with the Service Type updated to show the details of the selected WSDL and port, as shown in the following screenshot:
Then, click on Next. This will take us to the Transport Configuration page, as shown in the following screenshot. Here we need to specify how the business service is to invoke an external service.
As we based our business service on the EchoPort definition, the transport settings are already preconfigured, based on the content of our WSDL file.
Note
If we had based our business service on the EchoBinding definition, then the transport configuration would still have been prepopulated except for the Endpoint URI, which we would need to add manually.
From here, click on Last. This will take us to a summary page of our business service. Click on Save to create our business service.
This will return us to the project view on the Business Service folder and display the message The Service EchoBS was created successfully. If we examine the Resources section, we should see that it now contains our newly created business service.
Creating our proxy service
We are now ready to create our Echo proxy service. Click on the Proxy Service folder within the Project Explorer to go to the project view for this folder.
In the Resources section, click on the drop-down list next to Create Resource and select Proxy Service. This will bring up the General Configuration page for creating a proxy service, as shown in the following screenshot:
You will notice that this looks very similar to the general configuration screen for a business service. So as before, enter the name of our service (that is, Echo) and an optional description.
Next, we need to specify the Service Type. We could do this in exactly the same way as we did for our business service and base it on the Echo WSDL. However, this time we are going to base it on our EchoBS business service. We will see why in a moment.
For the Service Type, select Business Service, as shown in the screenshot, and click Browse…. This will launch the Select Business Service window from where we can search for and select the business service that we want to base our proxy service on.
By default, this window will list all the business services defined to the Service Bus, though you can restrict the list by defining the search criteria.
In our case, we just have the EchoBS, so select this, and click on Submit. This will return us to the General Configuration screen with Service Type updated, as shown in the following screenshot:
From here, click Last. This will take us to a summary page of our proxy service. Click Save to create our proxy service.
This will return us to the project view on the Proxy Service folder and display the message The Service Echo was created successfully.
If we examine the Resources section of our project view, we should see that it now contains our newly created proxy service as shown in the following screenshot:
Once we have created our
proxy service, the next step is to specify how it should handle requests. This is defined in the message flow of the proxy service.
The message flow defines the actions that the proxy service should perform when a request is received such as validating the payload, transforming, or enriching it before routing it to the appropriate business service.
Within the resource section of our project view, click on the Edit Message Flow icon, as circled in the preceding image. This will take us to the Edit Message Flow window, where we can view and edit the message flow of our proxy service, as shown in the following screenshot:
Looking at this, we can see that Echo already invokes the route node RouteTo_EchoBS.
Click on this and select Edit Route(as shown in the preceding screenshot). This will take us to the Edit Stage Configuration window, as shown in the following screenshot:
Here we can see that it's already configured to route requests to the EchoBS business service.
Normally, when we create a proxy service we have to specify the message flow from scratch. However, when we created our Echo proxy service we based it on the EchoBS business service (as opposed to a WSDL). Because of this, the Service Bus has automatically configured the message flow to route requests to EchoBS.
As a result, our message flow is already predefined for us, so click Cancel, and then Cancel again to return to our project view.
Activating the Echo proxy service
We now have a completed proxy service; all that remains is to commit our work. Within the Change Center click Activate.
This will bring up the Activate Session, as shown in the following screenshot:
Before activating a session, it's good practice to give a description of the changes that we've made, just in case we need to roll them back later. So enter an appropriate description and then click on Submit, as shown in the preceding screenshot:
Assuming everything is okay, this will activate our changes, and the console will be updated to list our configuration changes, as shown in the following screenshot:
If you make a mistake and want to undo the changes you have activated, then you can click on the undo icon (circled in the preceding screenshot), and if you change your mind, you can revert the undo.
OSB allows you to undo any of your previous sessions as long as it doesn't result in an error in the runtime configuration of the Service Bus.
Testing our proxy service
All that's left is to test our proxy service. A simple way to do this is to initiate a test instance using the Service Bus test console.
To do this, we need to navigate back to the definition of our proxy service, rather than do this via the Project Explorer. We will use the Resource Browser. This provides a way to view all resources based on their type.
Click on the Resource Browser section within the navigation bar. By default, it will list all proxy services defined to the Service Bus, as shown in the following screenshot:
We can then filter this list further by specifying the appropriate search criteria.
Click on the Launch Test Console icon for the Echo proxy service (circled in the preceding screenshot). This will launch the test console shown on the next page.
The
Available Operations drop-down list allows us to specify which operation we want to invoke. In our case, it's automatically defaulted to process.
By default, the options Direct Call and Include Tracing are selected within the Test Configuration section; keep these selected as they enable us to trace the state of a message as it passes through the proxy service.
The Request Document section allows us to specify the SOAP Header and the Payload for our service. By default, these will contain a skeleton XML fragment based on the WSDL definition of the selected operation with default values for each field.
To execute a test instance of our service, modify the text in the <echo:input>
element, as we have in the following screen shot, and click Execute. This will cause the console to generate a request message and use it to invoke our Echo proxy service.
Upon successful execution of the proxy, the test console will be updated to show the response returned. Here we can see that the result
element contains our original initial input string, as shown in the following screenshot:
We can examine the state of our message as it passed through the proxy service by expanding the Invocation Trace, as we have in the following screenshot:
In addition, if you log back into the EM console, you should be able to see the Assembly instance that was invoked by the Service Bus.