此内容没有您所选择的语言版本。

13.3. Running a SwitchYard Project on a JBoss Enterprise Application Server


To publish and run Fuse SwitchYard projects on an installed EAP server, you must first:
  • Install JBoss Fuse on the JBoss EAP server
  • Add the server and its runtime definition to the tooling's Servers list
    Once added to the list, the server appears in the Servers view, where you can configure it, start and stop it, and publish projects to it.
You can publish SwitchYard projects to Red Hat JBoss Enterprise Platform 6.4 and newer servers that you have defined and added to the Servers list.
Note
If you haven't already installed a server, you can do so when you define and add it to the Servers list.

Adding a JBoss EAP server

You can add a new server to the Servers view in three ways:
  • In Servers view, click the link No servers are available. Click this link to create a new server....
    Note
    This link appears in Servers view only when no server has been defined.
  • Right-click in Servers view to open the context menu, then select New Server.
  • On the menu bar, select File New Other Server Server.
  1. In the Define a New Server dialog, select Red Hat JBoss Enterprise Application Platform 6.1+.
    Server's host name and Server name are auto filled by default. In Server name, you can enter a different name to use to identify the server in the Servers view.
  2. Click Next to open the Create a New Server Adapter page.
    To specify that the server life-cycle is managed from outside the tooling, check Server is externally managed. Assume server is started..
    If you have not configured a runtime before, Create new runtime (next page) appears on the drop-down menu bar under The selected profile requires a runtime (as shown in the figure above). Otherwise, a previously configured runtime appears on the drop-down menu bar.
    Note
    You can assign the same runtime to multiple server instances, which enables you to quickly launch a server in debug mode or to configure other runtime settings.
  3. To use a previously created runtime with this server, click the drop-down menu and select it from the list (skip to Step 6).
    To create a new runtime, select Create new runtime (next page) from the list.
  4. Click Next to open the JBoss Runtime page.
    Note
    If the server is not already installed on your machine, you can install it now by clicking the link Download and install runtime... and following the site's download instructions. Depending on the site, you may be required to provide valid credentials before you can continue the download process.
  5. Configure the JBoss runtime:
    • Accept the default for Name, or enter a different name.
    • In Home Directory, enter the path where the server runtime is installed, or click Browse to find and select it.
    • Select the runtime JRE from the drop-down menu next to Execution Environment.
      If the version you want does not appear on the list, click Environments, and then select the version from the list. The JRE version you select must be installed on your machine.
    • Accept the defaults for Configuration base directory and Configuration file, or browse to the directory where the .xml configuration file to use is located.
  6. Click Finish.
    The server appears in the Servers view.

Importing a SwitchYard quickstart project

The JBoss Fuse on JBoss EAP installer installs the SwitchYard quickstarts in $EAP_HOME/quickstarts/switchyard/.
  1. Right-click in Project Explorer, and select Import Import... to open the Choose Import source dialog.
  2. In the Maven folder, select Existing Maven Projects.
  3. Click Next to open the Select Maven projects dialog.
  4. Click the Browse button next to the Root Directory field to locate and select the $EAP_HOME/quickstarts/switchyard/bean-service.
  5. In the Projects pane, make sure the pom.xml file entry for the switchyard-bean-service is selected.
  6. Click Finish to start the import.
    The switchyard-bean-service project appears in Project Explorer.
    Wait a moment for the import process to finish.

Testing a SwitchYard project locally

Before you try to publish your project to a server, it's useful to confirm that it builds and runs locally. The provided test files included with each SwitchYard quickstart are complete and comprehensive and need no modification.
  1. In Project Explorer, expand the switchyard-bean-service project to expose src/test/java/OrderServiceTest.java file.
    If you want to take a look at the test code, double-click the file to open it in the Java editor.
  2. In Project Explorer, right-click the OrderServiceTest.java file to open the context menu, and select Run As JUnit Test.
    Console view automatically opens and displays the log entries generated by the JUnit test.
    These log entries indicate that the test ran successfully against Apache Camel as expected.
  3. Click the JUnit tab to open JUnit view.
    This test proves that the switchyard-bean-service successfully builds and runs locally.

Publishing a SwitchYard project to the server

You can publish a project to a supported EAP server, defined and listed in the Servers view, whether it's running or not. A published project will run as scheduled according to the server's settings (for details, see (Chapter 29, Publishing Fuse Projects to a Server).
Important
The EAP server must have JBoss Fuse on JBoss EAP installed on it. For details, see Installation of JBoss Fuse on JBoss EAP
  1. In the Servers view, select the EAP 6.4 server you just added, and click on the menu bar to start it.
  2. In the Servers view, right-click the server to open the context menu, and select Add and Remove.
    When a project is ready for publishing, it appears in the Available column.
    Note
    The option If server is started, publish changes immediately is enable by default. See the section called “Publishing Fuse projects automatically when resources change” for information on how this option works and on using other publishing options.
  3. Double-click the project in the Available column to move it to the Configured column.
  4. Click Finish.
    Once publishing has finished, the project appears as a node under the server runtime node in the Servers view.
    Servers view shows that both the server runtime and the project are started and synchronized.
    Note
    For a server runtime, Synchronized means that all published resources on the server are identical to their local counterparts. For a published resource, Synchronized means that it is identical to its local counterpart.
  5. Look at the log output in Console view to confirm that the switchyard-bean-service project is deployed and running:

Testing the published SwitchYard project

You can use the JBoss Web Service Tester tool to test your published web service.
  1. From the log output in Console view, copy the address of the bean-service project's OrderService.
    In the example we are using, the address is http://localhost:8080/quickstart-bean/OrderService.
  2. Open a browser, and paste the address of the OrderService in the browser's address field.
  3. Add ?wsdl to the end of the address, so it reads http://localhost:8080/quickstart-bean/OrderService?wsdl.
  4. Press Enter.
    The browser displays the WSDL for the OrderService:
  5. Copy the URL in the browser's address field.
  6. In JBoss Developer Studio, click Window Show View Other, then scroll down to the JBoss Tools Web Services folder, and select Web Service Tester.
  7. Click the drop-down menu labeled GET, and select JAX-WS.
    The Request Body pane displays an example SOAP request message.
  8. Click next to to open the Specify the Source WSDL for the Web Service dialog, then paste the URL you copied in Step 5 into the WSDL URI field.
    The Web Service Tester auto fills the remaining fields with the data retrieved from the WSDL.
  9. Click OK.
    The Web Service Tester displays the XML request message retrieved from the WSDL in the Request Body pane.
    You can enter values for the <order> items <orderId>, <itemId>, and <quantity> to test the project's request and response services.
    Note
    You can discover what the data types are for each order item. In Project Explorer, double-click src/test/java/OrderServiceTest.java file to open it in the Java editor:
  10. In the Request Body pane, click the value field of each order item and enter an appropriate value for it. For example:
    • For <orderID>, replace ? with ORDER10
    • For <itemId>, replace ? with BUTTER
    • For <quantity>, replace 0 with 1000
  11. Click to the right of to invoke the submitOrder operation. and populate the Response Body pane with an example response message.
    Console view automatically opens to display the status of the submitOrder operation like this—
    ... INFO [stdout] (http-localhost/127.0.0.1:8080-2) |--- Validating Order object: [OrderID=ORDER10, 
           ItemID=BUTTER, quantity=1000] ---|
    
    ... INFO [stdout] (http-localhost/127.0.0.1:8080-2) |--- Validating OrderAck object: [OrderID=ORDER10,
           accepted=true, status=Order Accepted [intercepted]] ---|
    —at the end of the Console output.
  12. Switch to the Web Service Tester tool and check the response message in the Response Body pane.
Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

© 2024 Red Hat, Inc.