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

13.2. Running a SwitchYard Project on a JBoss Fuse Server


To publish and run Fuse SwitchYard projects on an installed Fuse server, you must first 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 JBoss Fuse 6.2.0 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 Fuse server

Follow the instructions in Section 28.1, “Adding a Server” to define and add an installed JBoss Fuse 6.2.1 server.

Installing the SwitchYard features on the server

JBoss Fuse is SwitchYard-ready, but you have to install the switchyard features.
  1. In the Servers view, select the JBoss Fuse server you just added, and click on the view's menu bar to start it up.
    Console view opens and displays the server's startup progress:
    Wait until [PATCH] Storing user changes appears at the end of the output.
  2. Switch to Shell view, and install the switchyard-* features, one after another, on the server:
    JBossFuse:admin@root> features:install switchyard-bean
    JBossFuse:admin@root> features:install switchyard-camel
    JBossFuse:admin@root> features:install switchyard-soap
    Note
    To see a list of all available SwitchYard-related features, enter features:list | grep switchyard*.
  3. Check that the switchyard-* features are installed and active:
    JBossFuse:admin@root> osgi:list
    The end of the output should show the switchyard components installed and active :

Importing a SwitchYard quickstart project

The SwitchYard quickstarts are installed in $FUSE_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 $FUSE_HOME/quickstarts/switchyard/bean-service.
  5. In the Projects pane, make sure the box next to the pom.xml file entry for the switchyard-bean-service is checked to select it.
  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.
    Note
    See the section called “Resolving Maven dependency errors” for details on what to do if you encounter Maven dependency errors, caused by failure to download all of the project's dependencies from the Maven repositories.
  7. In Project Explorer, right-click the switchyard-bean-service project to open the context menu, and select Enable Fuse Camel Nature.
    This option enables you to publish a switchyard project to the JBoss Fuse server, which you can do at any time now (for details, see the section called “Publishing a SwitchYard project to the server”).

Testing the SwitchYard quickstart project locally

It's a good idea to run projects as a JUnit test to check that they successfully build and run 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.
    The last two 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.
    Note
    If you failed to set the Execution environment to JavaSE-1.7 or JavaSE-1.8 when you defined the JBoss Fuse server, this test will fail. You can easily reset it by right-clicking the JRE System Library node in Project Explorer, and selecting Build Path Configure Build Path. In the Java Build Path dialog's Library tab, edit the current library to change the Execution environment setting to JavaSE-1.7 or JavaSE-1.8. (The library you select must be installed on your machine.) Then rerun the test.

Publishing a SwitchYard project to the server

You can publish a project to a supported 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).
  1. In the Servers view, right-click the target server to open the context menu, and then select Add and Remove.
    When a project is ready for publishing, it appears in the Available column. For example:
    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.
  2. Double-click the project in the Available column to move it to the Configured column.
  3. 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.
  4. In Shell view, enter the command osgi:list to confirm that the switchyard-bean-service project is installed and active.

Testing the published SwitchYard project

You can use the JBoss Web Service Tester tool to test your published web service.
  1. Open a web browser, and go to http://localhost:8181/cxf/ to see the available SOAP services with OrderService in the list.
    This site provides a link to the OrderService's WSDL.
  2. Click the link to the OrderService's WSDL to open it in the browser.
  3. In JBoss Developer Studio, click Window Show View Other, then scroll down to the JBoss Tools Web Services folder, and select Web Service Tester.
  4. Click the drop-down menu labeled GET, and select JAX-WS.
    The Request Body pane displays an example SOAP request message.
  5. Click next to to open the Specify the Source WSDL for the Web Service dialog, and then paste the URI you copied in Step 3 into the WSDL URI field.
    The Web Service Tester auto fills the remaining fields with the data retrieved from the WSDL.
  6. 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:
  7. 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
  8. 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 show the status of the submitOrder operation:
  9. 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.