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.このコンテンツは選択した言語では利用できません。
31.3. Publishing a Service in a Plain Java Application
Overview リンクのコピーリンクがクリップボードにコピーされました!
リンクのコピーリンクがクリップボードにコピーされました!
When you want to deploy your application as a plain java application you need to implement the logic for publishing your endpoints in the application's
main()
method. Apache CXF provides you two options for writing your application's main()
method.
- use the
main()
method generated by the wsdl2java tool - write a custom
main()
method that publishes the endpoints
Generating a Server Mainline リンクのコピーリンクがクリップボードにコピーされました!
リンクのコピーリンクがクリップボードにコピーされました!
The code generators
-server
flag makes the tool generate a simple server mainline. The generated server mainline, as shown in Example 31.2, “Generated Server Mainline”, publishes one service provider for each port
element in the specified WSDL contract.
For more information see Section E.2, “cxf-codegen-plugin”.
Example 31.2, “Generated Server Mainline” shows a generated server mainline.
Example 31.2. Generated Server Mainline
The code in Example 31.2, “Generated Server Mainline” does the following:
Writing a Server Mainline リンクのコピーリンクがクリップボードにコピーされました!
リンクのコピーリンクがクリップボードにコピーされました!
If you used the Java first development model or you do not want to use the generated server mainline you can write your own. To write your server mainline you must do the following:
- Instantiate an
javax.xml.ws.Endpoint
object for the service provider. - Create an optional server context to use when publishing the service provider.
- Publish the service provider using one of the
publish()
methods. - Stop the service provider when the application is ready to exit.
Example 31.3, “Custom Server Mainline” shows the code for publishing a service provider.
Example 31.3. Custom Server Mainline
The code in Example 31.3, “Custom Server Mainline” does the following: