Fuse 6 is no longer supported
As of February 2025, Red Hat Fuse 6 is no longer supported. If you are using Fuse 6, please upgrade to Red Hat build of Apache Camel.此内容没有您所选择的语言版本。
4.2. Deploy the Apache CXF Example
Overview 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
This tutorial takes a standard Apache CXF example (the
wsdl_first example) and shows you how to deploy it into a Web server, by packaging the application as a WAR. In this example, the Web service is implemented by binding the service to a Java class with the JAX-WS mapping.
Prerequisites 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
The following prerequisites are needed to build and run this example:
- Either of the following Web servers are installed:
- JBoss Web Server, or
- JBoss Enterprise Application Platform
- Java version 1.7 or later is installed.
- Apache Maven 3.0.0 or later is installed.
- Maven is configured to access the JBoss Fuse repositories, as described in Section 3.1, “Preparing to use Maven”.
- You have access to the Internet, so that Maven can download dependencies from remote repositories.
Install Apache CXF 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
To obtain the code for the
wsdl_first example, you need to install the Apache CXF kit, apache-cxf-3.1.5.redhat-630xxx.zip, provided in the extras/ directory of the JBoss Fuse installation.
Install the Apache CXF kit as follows:
- Find the Apache CXF kit at the following location:
InstallDir/extras/apache-cxf-3.1.5.redhat-630xxx.zip
InstallDir/extras/apache-cxf-3.1.5.redhat-630xxx.zipCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Using a suitable archive utility on your platform, unzip the
apache-cxf-3.1.5.redhat-630xxx.zipfile and extract it to a convenient location,CXFInstallDir.
The wsdl_first example 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
The
wsdl_first example is located under the following sub-directory of the Apache CXF installation:
CXFInstallDir/samples/wsdl_first/
CXFInstallDir/samples/wsdl_first/
Build and run the example 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
To build and run the
wsdl_first example, perform the following steps:
- Using your favorite text editor, open the
CustomerService.wsdlfile, which can be found in the following location in thewsdl_firstproject:wsdl_first/src/main/resources/CustomerService.wsdl
wsdl_first/src/main/resources/CustomerService.wsdlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Edit thesoap:addresselement in the WSDL contract, removing comments around the element labeledstandalone Tomcat deploymentand inserting comments around the element labeledembedded deployment. When you are finished editing, thesoap:addresselement should be look as follows:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Build the
wsdl_firstexample using Maven. Change directory to theCXFInstallDir/samples/wsdl_firstdirectory, open a command prompt, and enter the following command at the command line:mvn clean package
mvn clean packageCopy to Clipboard Copied! Toggle word wrap Toggle overflow If this command executes successfully, you should be able to find the WAR file,wsdl_first.war, under thewsdl_first/targetsub-directory. - Make sure that the Web server is already running (a simple way to test this is to enter the URL,
http://localhost:8080, into your browser). If you need to start the Web server, you can typically do this from the command line. The command to start the Web server depends on the particular product you are using, as follows:- JBoss Web Server (WS)—open a new command prompt and execute the
startup.shscript from thetomcat8/bin/directory (or thetomcat7/bin/directory, as appropriate). For more details about how to configure and launch the Web server, see the Installation Guide from the JBoss Web Server library. - JBoss Enterprise Application Platform (EAP)—for a standalone instance, open a new command prompt and execute the
bin/standalone.shscript. For more details about how to configure and launch the EAP, see the Administration and Configuration Guide from the JBoss Enterprise Application Platform library.
- Deploy the
wsdl_firstexample to the running Web server. Manually copy thewsdl_first.warWAR file from thewsdl_first/targetdirectory to the Web server's deployment directory, as follows:- JBoss Web Server (WS)—copy the
wsdl_first.warWAR file to thetomcat8/webappsdirectory (ortomcat7/webappsdirectory, as appropriate). - JBoss Enterprise Application Platform (EAP)—copy the
wsdl_first.warWAR file to thestandalone/deploymentsdirectory.
- Use a Web browser to query the WSDL contract from the newly deployed Web service. Navigate to the following URL in your browser:
http://localhost:8080/wsdl_first/services/CustomerServicePort?wsdl
http://localhost:8080/wsdl_first/services/CustomerServicePort?wsdlCopy to Clipboard Copied! Toggle word wrap Toggle overflow NoteThis step might not work in the Safari browser. - Run the test client against the deployed Web service. Change directory to the
CXFInstallDir/samples/wsdl_firstdirectory, open a command prompt, and enter the following command at the command line:mvn -Pclient
mvn -PclientCopy to Clipboard Copied! Toggle word wrap Toggle overflow If the client runs successfully, you should see some output like the following in your command window:Copy to Clipboard Copied! Toggle word wrap Toggle overflow